Blob Blame History Raw
From a04faf346426a9016ba5de85e3d6b8c93f7066e9 Mon Sep 17 00:00:00 2001
From: David Zeuthen <davidz@redhat.com>
Date: Fri, 05 Jun 2009 22:51:45 +0000
Subject: gphoto2: Fix gphoto2 backend to work with Canon EOS 5D

This bug was introduced during the 2.25 cycle as part of supporting
multiple storage heads. Previously we didn't use basedir, now we
do. And we failed to check if the basedir is actually set.
---
diff --git a/daemon/gvfsbackendgphoto2.c b/daemon/gvfsbackendgphoto2.c
index a21df89..9cc3851 100644
--- a/daemon/gvfsbackendgphoto2.c
+++ b/daemon/gvfsbackendgphoto2.c
@@ -56,7 +56,7 @@
 #include "gvfsicon.h"
 
 /* showing debug traces */
-#if 0
+#if 1
 #define DEBUG_SHOW_TRACES 1
 #endif
 
@@ -627,7 +627,7 @@ static void
 _gphoto2_logger_func (GPLogLevel level, const char *domain, const char *format, va_list args, void *data)
 {
   g_fprintf (stderr, "libgphoto2: %s: ", domain);
-  g_vfprintf (stderr, message, args);
+  g_vfprintf (stderr, format, args);
   va_end (args);
   g_fprintf (stderr, "\n");
 }
@@ -1340,7 +1340,9 @@ ensure_ignore_prefix (GVfsBackendGphoto2 *gphoto2_backend, GVfsJob *job)
       head = &storage_info[i];
     }
 
-  prefix = g_strdup_printf ("%s/", head->basedir);
+  /* Some cameras, such as the Canon 5D, won't report the basedir */
+  if (head->fields & GP_STORAGEINFO_BASE)
+    prefix = g_strdup_printf ("%s/", head->basedir);
 
  out:
 
@@ -1349,6 +1351,8 @@ ensure_ignore_prefix (GVfsBackendGphoto2 *gphoto2_backend, GVfsJob *job)
   else
     gphoto2_backend->ignore_prefix = prefix;
 
+  DEBUG ("Using ignore_prefix='%s'", gphoto2_backend->ignore_prefix);
+
   return TRUE;
 }
 
@@ -1992,7 +1996,7 @@ do_enumerate (GVfsBackend *backend,
   using_cached_file_list = FALSE;
 
   filename = add_ignore_prefix (gphoto2_backend, given_filename);
-  DEBUG ("enumerate (%s)", given_filename);
+  DEBUG ("enumerate ('%s', with_prefix='%s')", given_filename, filename);
 
   split_filename_with_ignore_prefix (gphoto2_backend, given_filename, &as_dir, &as_name);
   if (!is_directory (gphoto2_backend, as_dir, as_name))
diff --git a/monitor/gphoto2/ggphoto2volumemonitor.c b/monitor/gphoto2/ggphoto2volumemonitor.c
index 89a7f0b..b5ec0ec 100644
--- a/monitor/gphoto2/ggphoto2volumemonitor.c
+++ b/monitor/gphoto2/ggphoto2volumemonitor.c
@@ -452,11 +452,20 @@ get_stores_for_camera (int bus_num, int device_num)
   /* Append the data to the list */
   for (i = 0; i < num_storage_info; i++)
     {
+      const gchar *basedir;
+
       /* Ignore storage with no capacity (see bug 570888) */
       if ((storage_info[i].fields & GP_STORAGEINFO_MAXCAPACITY) &&
           storage_info[i].capacitykbytes == 0)
         continue;
-      l = g_list_prepend (l, g_strdup (storage_info[i].basedir));
+
+      /* Some cameras, such as the Canon 5D, won't report the basedir */
+      if (storage_info[i].fields & GP_STORAGEINFO_BASE)
+        basedir = storage_info[i].basedir;
+      else
+        basedir = "/";
+
+      l = g_list_prepend (l, g_strdup (basedir));
     }
 
 out:
--
cgit v0.8.2