aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2025-09-27 16:31:51 -0300
committerSilvio Rhatto <rhatto@riseup.net>2025-09-27 16:31:51 -0300
commit4f9b92264ff69efc3a0e69d809934acaaceb4d5b (patch)
tree287642480b4aaa93c501141feb61f715dc800351
parent6b85b7f6c54b7f2451be2e003dda773aa5272a8c (diff)
downloadhydra-4f9b92264ff69efc3a0e69d809934acaaceb4d5b.tar.gz
hydra-4f9b92264ff69efc3a0e69d809934acaaceb4d5b.tar.bz2
Fix: hydractl: sync-media:improved lock file handling
-rw-r--r--docs/changelog.md4
-rwxr-xr-xshare/hydractl/sync-media14
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