After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 749788 - gvfs-copy does not preserve timestamp
gvfs-copy does not preserve timestamp
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: mtp backend
1.20.x
Other Linux
: Normal enhancement
: ---
Assigned To: Philip Langdale
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2015-05-24 06:44 UTC by Jānis Elmeris
Modified: 2015-05-25 21:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
mtp: Copy mtime when pulling (1.85 KB, patch)
2015-05-24 07:28 UTC, Ross Lagerwall
committed Details | Review

Description Jānis Elmeris 2015-05-24 06:44:47 UTC
When using gvfs-copy --preserve from a MTP device to local, the timestamp is not preserved.

touch "localfile" --reference="MTP file" works ok.

Linux Mint 17 (based on Ubuntu 14.04), device Samsung Galaxy S4 I9505.

$ apt-show-versions gvfs
gvfs:amd64/trusty-updates 1.20.3-0ubuntu1 uptodate
gvfs:i386/trusty-updates 1.20.3-0ubuntu1 uptodate

$ apt-show-versions libmtp-common
libmtp-common:all/trusty 1.1.6-20-g1b9f164-1ubuntu2 uptodate

Reported and confirmed here: https://bugs.launchpad.net/ubuntu/+source/gvfs/+bug/1175947
Comment 1 Ross Lagerwall 2015-05-24 07:28:37 UTC
Created attachment 303875 [details] [review]
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.
Comment 2 Ross Lagerwall 2015-05-24 07:32:29 UTC
Phillip, is it possible to set the modification time when copying to the device (e.g. in do_push())?
Comment 3 Philip Langdale 2015-05-24 17:56:05 UTC
As far as I can tell, no, there's no attribute you can set to update the modification time.

Also, your change unconditionally copies the modification time, which isn't normal semantics. I never did this because it was never clear to me what '--preserve' means semantically, in terms of which properties to carry over and which not to. No other backend respects it either, so I had no guidance. I suppose it's fine to just copy the modification time and not worry about anything else, but you do need to make it conditional.
Comment 4 Philip Langdale 2015-05-24 17:57:44 UTC
Review of attachment 303875 [details] [review]:

Needs to respect the G_FILE_COPY_ALL_METADATA flag to decide whether to do it or not.
Comment 5 Ross Lagerwall 2015-05-24 18:44:12 UTC
(In reply to Philip Langdale from comment #3)
> As far as I can tell, no, there's no attribute you can set to update the
> modification time.
> 
> Also, your change unconditionally copies the modification time, which isn't
> normal semantics. I never did this because it was never clear to me what
> '--preserve' means semantically, in terms of which properties to carry over
> and which not to. No other backend respects it either, so I had no guidance.
> I suppose it's fine to just copy the modification time and not worry about
> anything else, but you do need to make it conditional.

Modification time is always copied (for guidance you can usually use the local file implementation).

To see this:
$ gvfs-info -w /etc/os-release
Settable attributes:
 standard::symlink-target (bytestring)
 time::access (uint64, Keep with file when moved)
 time::access-usec (uint32, Keep with file when moved)
 time::modified (uint64, Copy with file, Keep with file when moved)
 time::modified-usec (uint32, Copy with file, Keep with file when moved)
 unix::gid (uint32, Keep with file when moved)
 unix::mode (uint32, Copy with file, Keep with file when moved)
 unix::uid (uint32, Keep with file when moved)
Writable attribute namespaces:
 metadata (string, Copy with file, Keep with file when moved)
 xattr (string, Copy with file, Keep with file when moved)
 xattr-sys (string, Keep with file when moved)

Because time::modified is marked "Copy with file", it means that it must always be copied. If G_FILE_COPY_ALL_METADATA is specified, then all settable attributes should be copied.

I'm not sure if there're any other interesting attributes that should be maintained when pulling from a device.
Comment 6 Philip Langdale 2015-05-24 23:13:53 UTC
So that seems weird, in-so-far as it's not POSIX. When you 'cp' a file, the modification time is the time that you copied it.
Comment 7 Ross Lagerwall 2015-05-25 07:06:20 UTC
(In reply to Philip Langdale from comment #6)
> So that seems weird, in-so-far as it's not POSIX. When you 'cp' a file, the
> modification time is the time that you copied it.

There are many things about GIO that aren't POSIX-like :-)

So is it OK to commit then?
Comment 8 Philip Langdale 2015-05-25 16:20:27 UTC
(In reply to Ross Lagerwall from comment #7)
> (In reply to Philip Langdale from comment #6)
> > So that seems weird, in-so-far as it's not POSIX. When you 'cp' a file, the
> > modification time is the time that you copied it.
> 
> There are many things about GIO that aren't POSIX-like :-)
> 
> So is it OK to commit then?

Heh. Go ahead. Thanks for doing this.
Comment 9 Ross Lagerwall 2015-05-25 21:38:40 UTC
Pushed to master as fee67ba4e7c8edaccc5e858a53effe03d79cf461 and gnome-3-16 as 81a4d39e4aaf61dd3f9f2f1390e1fdaceb3eb91c. Thanks for the review.