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
}
#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 {} \;
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
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