[gnome-photos] local-item, media-server-item, utils: Don't query the mtime again



commit d8a18827d809884f7a99398120798a51820b0153
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Feb 23 01:14:10 2016 +0100

    local-item, media-server-item, utils: Don't query the mtime again
    
    We already know the mtime and have it in memory. No need to query it
    from the disk again.

 src/photos-local-item.c        |    4 +++-
 src/photos-media-server-item.c |    4 +++-
 src/photos-utils.c             |   16 +++++-----------
 src/photos-utils.h             |    1 +
 4 files changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/src/photos-local-item.c b/src/photos-local-item.c
index 62e36e9..8b03a6b 100644
--- a/src/photos-local-item.c
+++ b/src/photos-local-item.c
@@ -96,11 +96,13 @@ photos_local_item_create_thumbnail (PhotosBaseItem *item, GCancellable *cancella
   gboolean ret_val;
   const gchar *mime_type;
   const gchar *uri;
+  gint64 mtime;
 
   uri = photos_base_item_get_uri (item);
   file = g_file_new_for_uri (uri);
   mime_type = photos_base_item_get_mime_type (item);
-  ret_val = photos_utils_create_thumbnail (file, mime_type, cancellable, error);
+  mtime = photos_base_item_get_mtime (item);
+  ret_val = photos_utils_create_thumbnail (file, mime_type, mtime, cancellable, error);
 
   g_object_unref (file);
   return ret_val;
diff --git a/src/photos-media-server-item.c b/src/photos-media-server-item.c
index fe6daf9..c0186b1 100644
--- a/src/photos-media-server-item.c
+++ b/src/photos-media-server-item.c
@@ -74,11 +74,13 @@ photos_media_server_item_create_thumbnail (PhotosBaseItem *item, GCancellable *c
   gboolean ret_val;
   const gchar *mime_type;
   const gchar *uri;
+  gint64 mtime;
 
   uri = photos_base_item_get_uri (item);
   file = g_file_new_for_uri (uri);
   mime_type = photos_base_item_get_mime_type (item);
-  ret_val = photos_utils_create_thumbnail (file, mime_type, cancellable, error);
+  mtime = photos_base_item_get_mtime (item);
+  ret_val = photos_utils_create_thumbnail (file, mime_type, mtime, cancellable, error);
 
   g_object_unref (file);
   return ret_val;
diff --git a/src/photos-utils.c b/src/photos-utils.c
index fe75a09..2a26747 100644
--- a/src/photos-utils.c
+++ b/src/photos-utils.c
@@ -546,23 +546,18 @@ photos_utils_create_symbolic_icon_for_scale (const gchar *name, gint base_size,
 
 
 gboolean
-photos_utils_create_thumbnail (GFile *file, const gchar *mime_type, GCancellable *cancellable, GError 
**error)
+photos_utils_create_thumbnail (GFile *file,
+                               const gchar *mime_type,
+                               gint64 mtime,
+                               GCancellable *cancellable,
+                               GError **error)
 {
   GnomeDesktopThumbnailFactory *factory = NULL;
-  GFileInfo *info = NULL;
-  const gchar *attributes = G_FILE_ATTRIBUTE_TIME_MODIFIED;
   gboolean ret_val = FALSE;
   gchar *uri = NULL;
   GdkPixbuf *pixbuf = NULL;
-  guint64 mtime;
 
   uri = g_file_get_uri (file);
-  info = g_file_query_info (file, attributes, G_FILE_QUERY_INFO_NONE, cancellable, error);
-  if (info == NULL)
-    goto out;
-
-  mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED);
-
   factory = gnome_desktop_thumbnail_factory_new (GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE);
   pixbuf = gnome_desktop_thumbnail_factory_generate_thumbnail (factory, uri, mime_type);
   if (pixbuf == NULL)
@@ -581,7 +576,6 @@ photos_utils_create_thumbnail (GFile *file, const gchar *mime_type, GCancellable
  out:
   g_clear_object (&pixbuf);
   g_clear_object (&factory);
-  g_clear_object (&info);
   g_free (uri);
   return ret_val;
 }
diff --git a/src/photos-utils.h b/src/photos-utils.h
index 02332cf..3e0a000 100644
--- a/src/photos-utils.h
+++ b/src/photos-utils.h
@@ -85,6 +85,7 @@ GIcon           *photos_utils_create_symbolic_icon_for_scale (const gchar *name,
 
 gboolean         photos_utils_create_thumbnail            (GFile *file,
                                                            const gchar *mime_type,
+                                                           gint64 mtime,
                                                            GCancellable *cancellable,
                                                            GError **error);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]