[gvfs/gnome-3-16] mtp: Copy mtime when pulling



commit 81a4d39e4aaf61dd3f9f2f1390e1fdaceb3eb91c
Author: Ross Lagerwall <rosslagerwall gmail com>
Date:   Sun May 24 08:25:58 2015 +0100

    mtp: Copy mtime when pulling
    
    Copy the modification timestamp after copying a file from the device.
    Normally, this would be done in the copy fallback path, but if pull() is
    implemented, it must also copy metadata.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=749788

 daemon/gvfsbackendmtp.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c
index 4ecd988..1283978 100644
--- a/daemon/gvfsbackendmtp.c
+++ b/daemon/gvfsbackendmtp.c
@@ -1587,6 +1587,7 @@ do_pull (GVfsBackend *backend,
   GFile *local_file = NULL;
   GFileInfo *local_info = NULL;
   GFileInfo *info = NULL;
+  guint64 mtime;
 
   CacheEntry *entry = get_cache_entry (G_VFS_BACKEND_MTP (backend), source);
   if (entry == NULL) {
@@ -1693,6 +1694,19 @@ do_pull (GVfsBackend *backend,
     fail_job (G_VFS_JOB (job), device);
     goto exit;
   }
+
+  /* Ignore errors here. Failure to copy metadata is not a hard error */
+  mtime = g_file_info_get_attribute_uint64 (info,
+                                            G_FILE_ATTRIBUTE_TIME_MODIFIED);
+  g_file_set_attribute_uint64 (local_file,
+                               G_FILE_ATTRIBUTE_TIME_MODIFIED, mtime,
+                               G_FILE_QUERY_INFO_NONE,
+                               G_VFS_JOB (job)->cancellable, NULL);
+  g_file_set_attribute_uint32 (local_file,
+                               G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC, 0,
+                               G_FILE_QUERY_INFO_NONE,
+                               G_VFS_JOB (job)->cancellable, NULL);
+
   /* Attempt to delete object if requested but don't fail it it fails. */
   if (remove_source) {
     DEBUG ("(I) Removing source.\n");


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