diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2015-05-24 08:25:58 +0100 |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2015-05-25 22:34:53 +0100 |
commit | fee67ba4e7c8edaccc5e858a53effe03d79cf461 (patch) | |
tree | 8b205b20c87e2e62387af5146c8c6da9d640a2a3 /daemon/gvfsbackendmtp.c | |
parent | b7f417e5db9c3f0a0077145921b9de1e2244afa9 (diff) | |
download | gvfs-fee67ba4e7c8edaccc5e858a53effe03d79cf461.tar.gz |
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
Diffstat (limited to 'daemon/gvfsbackendmtp.c')
-rw-r--r-- | daemon/gvfsbackendmtp.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/daemon/gvfsbackendmtp.c b/daemon/gvfsbackendmtp.c index 4ecd988a..12839782 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"); |