]> gitweb.fluxo.info Git - hydra.git/commitdiff
Fix: hydractl: sync-media: workflow improvements
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 19 Oct 2023 18:16:50 +0000 (15:16 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 19 Oct 2023 18:16:50 +0000 (15:16 -0300)
share/hydractl/sync-media

index 12d9b696770b24b39d798a70d775f81ed17fe7a0..48b03b7810635eeda46419c1d7d3267eca1ba1b8 100755 (executable)
@@ -53,6 +53,10 @@ function sync_media_add {
 
 # Add meta files, making sure they're handled directly by Git
 function sync_media_add_metadata {
+  # Playlist files
+  find -name '*.m3u' -type l -exec git annex unlock {} \;
+  find -name '*.m3u'         -exec git add {} \;
+
   # Koreader metadata files
   find -name metadata.pdf.lua     -type l -exec git annex unlock {} \;
   find -name metadata.pdf.lua             -exec git add {} \;
@@ -206,13 +210,32 @@ for folder in $REPOSITORIES; do
     cd $CACHE/$folder
     echo "Syncing $CACHE/$folder..."
 
-    sync_media_add_metadata
-    sync_media_playlist_perms
+    # Ensure the removable volume is in the list of remotes
     sync_media_ensure_remote $REMOTE $VOLUME/$MEDIA/$folder
+
+    # Ensure the repository is identified
     sync_media_identity
+
+    # Sync before changing anything, to make sure the history does not have
+    # conflicts with other remotes
+    git annex sync
+
+    # Fix any playlist permissions
+    sync_media_playlist_perms
+
+    # Process metadata
+    sync_media_add_metadata
+
+    # Add new content, and catch up changes
     sync_media_add
+
+    # Sync everything again
     git annex sync
+
+    # Get all that needs to be got
     sync_media_getall $CACHE/$folder
+
+    # Repository maintenance
     sync_media_fsck
     sync_media_dropunused
     )