aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xshare/hydractl/sync-media29
1 files changed, 23 insertions, 6 deletions
diff --git a/share/hydractl/sync-media b/share/hydractl/sync-media
index 11bbd4f..b7840e5 100755
--- a/share/hydractl/sync-media
+++ b/share/hydractl/sync-media
@@ -60,18 +60,23 @@ function sync_media_unset_lockfile {
function sync_media_check_lockfile {
local pid process
- git ignore $LOCK
+ if [ ! -e ".gitignore" ] || ! grep -q "$LOCK" .gitignore; then
+ git ignore $LOCK
+ fi
if [ ! -z "$LOCKFILE" ] && [ -f "$LOCKFILE" ]; then
pid="`cat $LOCKFILE`"
process="`ps --no-headers -o comm $pid`"
if [ "$?" == "0" ] && [ "`ps --no-headers -o comm $$`" == "$process" ]; then
- fatal "Another program is running for $LOCKFILE, skipping run"
+ echo "Another program is running for $LOCKFILE, skipping"
+ return 1
else
echo "Found old lockfile $LOCKFILE, removing it"
sync_media_unset_lockfile
fi
+
+ return 0
fi
}
@@ -118,6 +123,12 @@ function sync_media_add_metadata {
#metadata_state="unlock"
metadata_state="unannex"
+ # Gitignore
+ if [ -e ".gitignore" ]; then
+ git annex $metadata_state .gitignore
+ git add .gitignore
+ fi
+
# Playlist files in the playlist folder
if [ -d "playlists" ]; then
find playlists -name '*.m3u' -type l -exec git annex $metadata_state {} \;
@@ -287,8 +298,11 @@ for folder in $REPOSITORIES; do
echo "Syncing $CACHE/$folder..."
# Lockfile handling
- sync_media_check_lockfile
- sync_media_set_lockfile
+ if ! sync_media_check_lockfile; then
+ continue
+ else
+ sync_media_set_lockfile
+ fi
# Ensure the removable volume is in the list of remotes
sync_media_ensure_remote $REMOTE $VOLUME/$MEDIA/$folder
@@ -382,8 +396,11 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then
echo "Syncing $VOLUME/$MEDIA/$folder..."
# Lockfile handling
- sync_media_check_lockfile
- sync_media_set_lockfile
+ if ! sync_media_check_lockfile; then
+ continue
+ else
+ sync_media_set_lockfile
+ fi
sync_media_playlist_perms
sync_media_ensure_remote $HOST $CACHE/$folder