]> gitweb.fluxo.info Git - scripts.git/commitdiff
Minor copy-annotations-from-kobo enhancements (2)
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 1 Jan 2023 19:30:42 +0000 (16:30 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 1 Jan 2023 19:30:42 +0000 (16:30 -0300)
copy-annotations-from-kobo

index 271328f01f6026f705c96182bb2a1dea264cb91d..19c894ceafe2efeb348c930f1a1f2a7aca8e8fb5 100755 (executable)
@@ -14,7 +14,8 @@ PATTERN="$1"
 #        https://serverfault.com/questions/36421/stop-ssh-login-from-printing-motd-from-the-client#38160
 function silentSsh {
     local connectionString="$1"
-    local commands="$2"
+    shift
+    local commands="$*"
     if [ -z "$commands" ]; then
         commands=`cat`
     fi
@@ -34,6 +35,19 @@ show --search "$PATTERN" | while read item; do
   extension="$(echo $item | sed -e "s|$basename.||")"
   sdr="$basename.sdr"
 
+  # Check if remote file exists
+  silentSsh $REMOTE <<EOT
+    test -e "$REMOTE_BASE/$sdr/metadata.$extension.lua"
+EOT
+
+  # Skip if remote file does not exist
+  if [ "$?" != "0" ]; then
+    echo "Skipping $item as it's not available at $REMOTE..."
+    continue
+  fi
+
+  echo "Processing $item..."
+
   # Make sure that the annotation file exists
   mkdir -p "$BASEFOLDER/$sdr"
   touch "$BASEFOLDER/$sdr/metadata.$extension.lua"