diff options
-rwxr-xr-x | share/hydractl/sync-media | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/share/hydractl/sync-media b/share/hydractl/sync-media index 39b1ab3..c486ff7 100755 --- a/share/hydractl/sync-media +++ b/share/hydractl/sync-media @@ -191,15 +191,21 @@ for folder in `ls $CACHE`; do if [ ! -z "$DRIVE" ]; then mkdir -p $VOLUME/$MEDIA - if [ -d "$CACHE/$folder/.git/annex" ]; then + if [ -d "$CACHE/$folder/.git" ]; then if [ ! -d "$VOLUME/$MEDIA/$folder" ]; then ( cd $VOLUME/$MEDIA echo "Initializing $VOLUME/$MEDIA/$folder..." - git clone $CACHE/$folder && cd $folder && sync_media_identity && git annex init $DRIVE && \ - git remote rename origin $HOST && git config sync-media.getall true && \ - cd $CACHE/$folder && git remote add $DRIVE $VOLUME/$MEDIA/$folder + git clone $CACHE/$folder && cd $folder && sync_media_identity && git remote rename origin $HOST + cd $CACHE/$folder && git remote add $DRIVE $VOLUME/$MEDIA/$folder ) + + if [ -d "$CACHE/$folder/.git/annex" ]; then + ( + cd $VOLUME/$MEDIA + git annex init $DRIVE && git config sync-media.getall true + ) + fi fi elif [ ! -d "$VOLUME/$MEDIA/$folder" ]; then mkdir -p $VOLUME/$MEDIA/$folder @@ -233,7 +239,7 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then sync_media_dropunused #git annex drop --auto --numcopies=2 ) - elif [ -d "$CACHE/$folder" ]; then + elif [ -d "$CACHE/$folder" ] && [ ! -d "$CACHE/$folder/.git" ]; then # Avoid those configured to be skipped if [ ! -e "$CACHE/$folder/.sync-media/skip" ]; then echo "Syncing $CACHE/$folder with $VOLUME/$MEDIA/$folder..." @@ -252,13 +258,20 @@ if [ ! -z "$DRIVE" ] && [ -d "$VOLUME/$MEDIA" ]; then # Ensure the local cache has each repository listed in the removable media if [ ! -d "$CACHE/$folder" ]; then - if [ -d "$VOLUME/$MEDIA/$folder/.git/annex" ]; then + if [ -d "$VOLUME/$MEDIA/$folder/.git" ]; then ( cd $CACHE echo "Initializing $CACHE/$folder..." - git clone $VOLUME/$MEDIA/$folder && cd $folder && sync_media_identity && git annex init $HOST && \ - git remote rename origin $REMOTE && cd $VOLUME/$MEDIA/$folder && git remote add $HOST $CACHE/$folder + git clone $VOLUME/$MEDIA/$folder && cd $folder && sync_media_identity && git remote rename origin $REMOTE + cd $VOLUME/$MEDIA/$folder && git remote add $HOST $CACHE/$folder ) + + if [ -d "$VOLUME/$MEDIA/$folder/.git/annex" ]; then + ( + cd $CACHE + git annex init $HOST + ) + fi else echo "Syncing $VOLUME/$MEDIA/$folder into $CACHE/$folder..." rsync -av --delete --exclude=.sync-media $VOLUME/$MEDIA/$folder/ $CACHE/$folder/ |