diff options
Diffstat (limited to 'share')
-rwxr-xr-x | share/hydractl/sync-media | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/share/hydractl/sync-media b/share/hydractl/sync-media index 08d6280..11bbd4f 100755 --- a/share/hydractl/sync-media +++ b/share/hydractl/sync-media @@ -50,6 +50,7 @@ function sync_media_set_lockfile { # Adapted from borger function sync_media_unset_lockfile { if [ ! -z "$LOCKFILE" ]; then + git annex unannex $LOCK rm -f $LOCKFILE || echo "Could not remove lockfile $LOCKFILE" fi } @@ -59,13 +60,12 @@ function sync_media_unset_lockfile { function sync_media_check_lockfile { local pid process + git ignore $LOCK + if [ ! -z "$LOCKFILE" ] && [ -f "$LOCKFILE" ]; then pid="`cat $LOCKFILE`" process="`ps --no-headers -o comm $pid`" - git annex unannex $LOCK - git ignore $LOCK - if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then fatal "Another program is running for $LOCKFILE, skipping run" else @@ -369,6 +369,7 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then # Iterate over existing repositories in the removable media for folder in $REPOSITORIES; do + LOCKFILE="$VOLUME/$MEDIA/$folder/$LOCK" # Sync each local repository in the removable media if [ -d "$VOLUME/$MEDIA/$folder/.git/annex" ]; then @@ -380,6 +381,10 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then cd $VOLUME/$MEDIA/$folder echo "Syncing $VOLUME/$MEDIA/$folder..." + # Lockfile handling + sync_media_check_lockfile + sync_media_set_lockfile + sync_media_playlist_perms sync_media_ensure_remote $HOST $CACHE/$folder sync_media_identity @@ -396,6 +401,9 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then git gc git prune #git annex drop --auto --numcopies=2 + + # Unset the lockfile + sync_media_unset_lockfile ) elif [ -d "$CACHE/$folder" ] && [ ! -d "$CACHE/$folder/.git" ]; then # Avoid those configured to be skipped |