diff options
-rw-r--r-- | docs/changelog.md | 4 | ||||
-rwxr-xr-x | share/hydractl/sync-media | 14 |
2 files changed, 13 insertions, 5 deletions
diff --git a/docs/changelog.md b/docs/changelog.md index 4cf0afb..011c3bb 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -24,5 +24,5 @@ files and manage them through Git, instead of keeping them as unlocked files. * [x] Added support for `.m3u8` files. - * [x] Sync lock, respected by other applications such as `docshower` - from [utils-doc][https://git.fluxo.info/utils-doc]. + * [x] Sync lock for git-annex repositories, respected by other applications + such as `docshower` from [utils-doc][https://git.fluxo.info/utils-doc]. 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 |