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