diff options
Diffstat (limited to 'share/hydractl/sync-media')
-rwxr-xr-x | share/hydractl/sync-media | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/share/hydractl/sync-media b/share/hydractl/sync-media index 88c8901..0976c68 100755 --- a/share/hydractl/sync-media +++ b/share/hydractl/sync-media @@ -67,8 +67,8 @@ function sync_media_add_metadata { find -name metadata.pdf.lua.old -exec git add {} \; # Darktable sidecar files - find -name '*.xmp' -type l ! -path '*.git' -exec git annex unlock {} \; - find -name '*.xmp' ! -path '*.git' -exec git add {} \; + find -name '*.xmp' -type l -not -path '*.git*' -exec git annex unlock {} \; + find -name '*.xmp' -not -path '*.git*' -exec git add {} \; } # If there is a playlists folder, make sure mpd user can write to it @@ -136,7 +136,7 @@ function sync_media_ensure_remote { local remote="$1" local path="$2" - if [ -z "$remote" ] || [ "$remote" == "local" ] || [ -z "$path" ]; then + if [ -z "$remote" ] || [ "$remote" == "local" ] || [ "$remote" == "localhost" ] || [ -z "$path" ]; then return fi @@ -171,12 +171,16 @@ if echo $OPTIONS | grep -q -- "--dropunused"; then fi # Set drive config -# Ingore drive/volume if it's set to "local" -if [ ! -z "$REMOTE" ] && [ "$REMOTE" != "local" ]; then +# Ignore drive/volume if it's set to "local" +if [ ! -z "$REMOTE" ] && [ "$REMOTE" != "local" ] && [ "$REMOTE" != "localhost" ]; then # Check storage media MOUNT="`mount | grep $VOLUME`" + if [ ! -z "$MOUNT" ]; then DRIVE="$(basename `echo $MOUNT | awk '{ print $1 }'`)" + #else + # echo "$BASENAME: volume $MEDIA is not mounted" + # exit 1 fi fi @@ -219,9 +223,12 @@ for folder in $REPOSITORIES; do # Ensure the repository is identified sync_media_identity + # Disable automatic syncing of content + git config annex.synccontent false + # Sync before changing anything, to make sure the history does not have # conflicts with other remotes - git annex sync + git annex sync --no-content # Fix any playlist permissions sync_media_playlist_perms @@ -233,7 +240,7 @@ for folder in $REPOSITORIES; do sync_media_add # Sync everything again - git annex sync + git annex sync --no-content # Get all that needs to be got sync_media_getall $CACHE/$folder @@ -241,6 +248,8 @@ for folder in $REPOSITORIES; do # Repository maintenance sync_media_fsck sync_media_dropunused + git prune + git gc ) fi @@ -299,11 +308,17 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then sync_media_ensure_remote $HOST $CACHE/$folder sync_media_identity sync_media_add - git annex sync + + # Disable automatic syncing of content + git config annex.synccontent false + + git annex sync --no-content sync_media_get $VOLUME/$MEDIA/$folder sync_media_getall $VOLUME/$MEDIA/$folder sync_media_fsck sync_media_dropunused + git gc + git prune #git annex drop --auto --numcopies=2 ) elif [ -d "$CACHE/$folder" ] && [ ! -d "$CACHE/$folder/.git" ]; then @@ -375,7 +390,7 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then fi fi done -elif [ ! -z "$REMOTE" ] && [ "$REMOTE" != "local" ]; then +elif [ ! -z "$REMOTE" ] && [ "$REMOTE" != "local" ] && [ "$REMOTE" != "localhost" ]; then # Try to copy to a remote for folder in `ls $CACHE`; do if [ -d "$CACHE/$folder/.git/annex" ]; then @@ -388,7 +403,7 @@ elif [ ! -z "$REMOTE" ] && [ "$REMOTE" != "local" ]; then ( cd $CACHE/$folder git annex copy . --to $REMOTE - git annex sync + git annex sync --no-content ) else echo "Syncing $CACHE/$folder with ssh://$REMOTE.$DOMAIN/$CACHE/$folder..." |