warpinator-android icon indicating copy to clipboard operation
warpinator-android copied to clipboard

Preserving file modification timestamps - Android app's or Linux app's fault or inbetween the two?

Open STPKITT opened this issue 3 years ago • 6 comments

Hello, I tried out transfering files between my Android smartphone and a Linux PC of mine. The smartphone is running LineageOS 16.0 which is basically Android 9. I installed warpinator-android via F-Droid which currently means version 1.4.6 of the app. The Linux PC is running KDE neon User edition and on there I installed the Warpinator Flatpak package which currently ships Warpinator 1.2.9. Due to my experience with KDE Connect's filetransfer feature I was aware of potential issues regarding file modification timestamps when using Warpinator so I immediately had a look at the behaviour when transfering files between PC and smartphone using Warpinator. Here are my test results:

Sending a file from PC to smartphone: the file modification timestamp of the target file gets changed to the moment of the transfer which is bad.

Sending a file from smartphone to PC: the file modification timestamp of the target file is the same as the source file which is the desired result.

At first I posted this to the issue tracker of Warpinator for Linux but user @mtwebster reported back that the issue doesn't seem to exist when transfering files from Linux PC to another Linux PC using the exact same Warpinator release (Flatpak 1.2.9) as I did. The corresponding issue on the issue tracker of the Warpinator for Linux can be found at [mtwebster](url).

I now opening this issue here since the Android app seems to play a role here but it's for the experts here to find out if the fix is just on the Android side or if both sides have to apply changes to make it work correctly.

STPKITT avatar Jul 18 '22 21:07 STPKITT

Hi, sorry for the late reply. This is a problem on the Android side. Unfortunately it is not possible to set last modification timestamps on Android with the Storage Access Framework API. It is possible to do that with the old File API but this was greatly restricted in Android 11 and later. Now only certain folders can be used to save files into. When you clear the app's data (reset the settings) the default download directory will be Download/Warpinator and the file modification dates of received files will be kept. Once you change it to anything else they will not be kept anymore. One "proper" solution would be to ask for the MANAGE_EXTERNAL_STORAGE permission. It would allow us to use the File API everywhere. This however would likely be rejected by Google Play as the purpose of the app is not explicitly file management. ~~Another solution could be to save the file with SAF and then change the timestamp with File API. Not sure if this will work though, will have to try and find out.~~ Doesn't work. I'll add a warning that using a non-default download directory doesn't preserve the timestamp and an option to reset without clearing data.

slowscript avatar Jul 26 '22 11:07 slowscript

Linux version: 1.4.5 on Linux Mint 21.1 ; Android version: 1.6.1 on LineageOS 20 Hello, I encounter problems that I didn't find the pictures I sended them to phone. Obviously due sorting in Gallery and false file timestamps... I figure out the following.

Send from computer to phone. In this case Files timestamps are preserved.

Send from phone to computer. Files timestamps created/modified have value of moment when I send them to computer. Ok, not bad. This is most likely the common way, generaly said.

Sending between two phones. Here we have a big problem! File timestamps are allways set to 1.1.1970, 1:00 Anything else will be much better than this. Due such timestamps all gallery apps sort recieved pictures wrong (pictures havent EXIF metadata!) and file managers don't show recived files in category recent files.

I would suggest standard behavior in all cases the same. This menans files get the timestamp of the moment when they are sended. Just see behavior if you just copy files in local drive in windows/linux - this I mean as standard / expected behavior. No problem if you put chekbox in warpinator's settings and implement requested feature to preserve file timestap. This will be very welcome.

neco154 avatar May 23 '23 10:05 neco154

No, in Windows/Linux it's the file creation date that might be set to the moment of copying, but the file modification timestamps, which this bug is all about, is kept intact.

@slowscript what about working around the issue by putting everything into a temporary zip- or 7z-file before sending and extracting the sent files automatically on the target, everything happening behind the scenes without the user ever noticing. It would need to be tested first though if that workaround actually leads to the correct timestamps.

STPKITT avatar May 23 '23 11:05 STPKITT

@STPKITT Unfortunately this would not work. The Storage Access Framework simply does not allow me to set the timestamp on files, even if they were just extracted from an archive. Other apps can avoid having to use SAF by asking for the "Manage All Files" permission, but Google is very picky about letting apps that use it on Google Play. This wasn't necessary before Android 11...

@neco154 I can add an option to disable setting the timestamp, although that is not what most users want. For now you can try a workaround - just select a non-default download folder in Warpinator's settings.

The 1970 date is probably a bug. When sending a file, the app gets the timestamp from the provider of the file - the system file picker, the media library (when you select it from e.g. Videos, rather than navigating the folder structure) or the app it was shared from. Sometimes the provider doesn't give us the timestamp or sets it to zero, which is 1.1.1970.

slowscript avatar May 23 '23 12:05 slowscript

No no, further option is not needed. I see, that I and STPKITT want the same - standard behavior just like copy a file in local drive in windows/linux.

Is it mostly about concern that google will refuse app? @slowscript Maybe look the open source app LocalSend how is there done. I prefer Warpinator because is way faster!

Plan B. Maybe just let user to choose allow access to all files or not. Lead the user to the switch in android system settings (open this window). Workaround works - select a non-default download folder, but nobody knows this. However, default settings should work well.

neco154 avatar May 23 '23 14:05 neco154

I have to try the workaround and which result it gives me. I'm not as current as Android 11 on my devices.

@STPKITT Ok, I understand my workaround won't work then. What about a separate Warpinator release called F-Droid edition or something like that. I don't use anything from Google anyway and it would fit the whole Linux/FOSS-theme.

STPKITT avatar May 23 '23 15:05 STPKITT