Camera import - warn of duplicate filenames
authorColin Clark <cclark@carbon>
Wed, 5 Jun 2019 09:32:53 +0000 (10:32 +0100)
committerColin Clark <cclark@carbon>
Wed, 5 Jun 2019 09:32:53 +0000 (10:32 +0100)
Digital cameras can have files of the same name in several sub-folders.
Detect this and warn the user that some files will not be downloaded.

doc/docbook/GuideReferenceStandardPlugins.xml
plugins/camera-import/geeqie-camera-import

index 2d1e779..bfbde9a 100644 (file)
   <section id="Cameraimport">\r
     <title>Camera import</title>\r
     <para>Imports images from an attached camera to the current folder. If a file with the same name already exists it will not be overwritten, and the new image will not be downloaded.</para>\r
+    <para>File names on digital cameras are not necessarily unique. In some cases the same file name can exist in more than one sub-folder on the camera. As existing images will not be overwritten, subsequent files of the same name will not be downloaded. In this case a dialog will be shown to warn you of this.</para>\r
+    <para>\r
+      You may use the gphoto2 option\r
+      <code>--filename</code>\r
+      option to ensure that all filenames are unique when downloading. Refer to the\r
+      <ulink url="http://www.gphoto.org/doc/manual/ref-gphoto2-cli.html">gphoto2 documentation.</ulink>\r
+    </para>\r
     <para>\r
       This item is displayed in the\r
       <emphasis role="strong">Plugins</emphasis>\r
index 40cca5f..943617b 100755 (executable)
@@ -113,6 +113,17 @@ fi
 ls -1 | sort > $dest_files_sorted
 existing_file_count=$(comm -12 $src_files_sorted $dest_files_sorted | wc -l)
 
+repeated=$(uniq --repeated $src_files_sorted)
+if [ ! -z "$repeated" ]
+then
+       repeated="Warning: The following source filenames are not unique.\nSome files may not be downloaded.\nSee the Help file.\n\n$repeated"
+       zenity --question --text="$repeated" --title="Geeqie camera import" --cancel-label="OK" --ok-label="Cancel" --width=400 --window-icon=/usr/local/share/pixmaps/geeqie.png 2>/dev/null
+       if [[ $? == 0 ]]
+       then
+               exit 1
+       fi
+fi
+
 total=$(cat $src_files_sorted | wc -l)
 files_to_load=$(( $total - $existing_file_count ))