diff options
| author | Silvio Rhatto <rhatto@riseup.net> | 2025-09-27 16:31:51 -0300 |
|---|---|---|
| committer | Silvio Rhatto <rhatto@riseup.net> | 2025-09-27 16:31:51 -0300 |
| commit | 4f9b92264ff69efc3a0e69d809934acaaceb4d5b (patch) | |
| tree | 287642480b4aaa93c501141feb61f715dc800351 /share | |
| parent | 6b85b7f6c54b7f2451be2e003dda773aa5272a8c (diff) | |
| download | hydra-4f9b92264ff69efc3a0e69d809934acaaceb4d5b.tar.gz hydra-4f9b92264ff69efc3a0e69d809934acaaceb4d5b.tar.bz2 | |
Fix: hydractl: sync-media:improved lock file handling
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 |
