Closed lmagyar closed 3 weeks ago
FYI: And now I've tested it with even directories, this works even on them!
Ok, that sounds all good
Many Thanks
OMG. 6 years.
OMG. 6 years.
:) All credit goes to https://stackoverflow.com/users/15401262/usilo
One strange issue, seems to be an Android bug:
So it seems Android caches this mtime info, though the backing FAT32 FS stores only even-integer truncated values. When the cache is deleted and values are read from the real FS, timestamp magically changes...
This made me mad, I'm trying to create a bidirectional sync script, and even if I read back the "real" timestamp with STAT after SETSTAT, files started to change "randomly" during the night. They got 1 second older. Only the ones, that were odd-something seconds old on the previous day...
Android, what a mess...
Now I'm investigating where to put the workaround, in the ftpd server or in the sync script, I have to find a way to determine the filesystem's mtime resolution.
In theory it is not possible:
DocumentsContract.Document.COLUMN_LAST_MODIFIED
is read-only.In reality it is possible: we can't write the SD card's files with the file API, but we can set the attributes with the file API (what we can't through SAF, "great" design).
The solution is a copy-paste from https://stackoverflow.com/questions/63495498/android-scoped-storage-getcontentresolver-update-column-last-modified/66681306#66681306
Note: I also removed the
sshFile.setLastModified(new Date().getTime());
call in each SSH_FXP_WRITEfixes #145
Tested on Android 9.0, Samsung A8