-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Android bug on FAT32/exFAT SD card time resolution and mtime caching #360
Conversation
Not the latest logs, but some proof it works.
Real FAT32 card:
The |
primitiveFTPd/src/org/primftpd/filesystem/StorageManagerUtil.java
Outdated
Show resolved
Hide resolved
primitiveFTPd/src/org/primftpd/filesystem/SafSshFileSystemView.java
Outdated
Show resolved
Hide resolved
primitiveFTPd/src/org/primftpd/filesystem/SafFtpFileSystemView.java
Outdated
Show resolved
Hide resolved
primitiveFTPd/src/org/primftpd/filesystem/SafFtpFileSystemView.java
Outdated
Show resolved
Hide resolved
I'm really looking forward to that merge script 😄 |
The Python sync? 😄 It is working, I've added remote management (start/stop, with Automate or HomeAssistant) for Tailscale, pFTPd, Termux/sshd services (the later for inotifywait, to catch the changes on the fly). I need a few hours net to finalize it on to a v0.1 quality level, though with a newborn and a relocation I hardly find time to sleep. 😨 I will work on the tech comments above on next week. |
Happy coding between moving boxes and with new born on arm 😄 |
Yeah, this description is quite accurate. :) Just a note: Android inaccurate on file mod. times not only on files we have uploaded, but on eg. new pictures. When we download a fresh new picture through plain-old FS from the SD card, it will have an inaccurate timestamp, but a few hours later it will be rounded to 2s (in case of FAT32) and my sync script will download it again. Not a big issue, doesn't happen too often, but an issue, especially when I delete the downloaded file, and the delete and "modification" causes a conflict. So this solution should be extended to RoSaf and plain-old FS (when we access files under /fs/storage/XXXX-XXXX). Not a big problem, but it needs some time. |
c126869
to
1b18ecc
Compare
6570c60
to
60aaff7
Compare
After some "working, but I don't like it" versions, this is the minimalistic version:
Issues:
Now if I make new pictures with the camera, stored on the SD card, sync it to the laptop (through poFS, roSAF or SAF), the timestamps will be the correct even seconds immediatelly and not only after a few hours (causing another sync or sync conflict if I deleted them meantime on the laptop). |
Draft again, I will refactor some details (no functional change). |
It's ready for review again. Added caching and made some refactor The long comment above summarizing the changes got updated! |
… as argument from ctors
b627111
to
58b0731
Compare
Merge conflicts resolved. |
OK, conflicts are really fixed now, it builds. :D |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole topic is still unbelievable. I would have never put so much effort just in timestamps.
One thing I noticed:
Now Fs..File objects have some relation to SAF. I'm going to add comments about that.
As I wrote in #351 (comment), Android lies about the lastModifiedTime. Even the specs says, that if the time resolution is lower than what we ask, the next getLastModifiedTime will give back the "truncated" value, this is simply not true (tested on real phone, Android 9.0 and emulator). It gives back the truncated values only when he wants, usually hours later. This is an unpredictable nightmare.
This fix:
StorageManagerUtil
class that detects SAF filesystems from/proc/mounts
, it detects:10ms2000msfileSystemView
property fromSafSshFile
up toSafFile
, so all SAF file can call the newgetTimeResolution()
fromSafFileSystemView
Update:
Maybe the default 1ms is overkill, in theory FTP has sub-second resolution, though we can modify StorageManagerUtil to return only 1000 vs 2000 ms, in this case no overload needed inSafSshFileSystemView
to limit sub second resolution to the 1s resolution of sftp messages.