Why default modTimeWindowS to 2 for FAT only on Android?

As far as I understand, the FAT file system uses imprecise timestamps regardless of the OS. What is the reason for applying the default value of 2 on Android only? Would it not be better to always apply it when finding a FAT partition and remove the OS check altogether?

The relevant part of the code:

For reference: https://forum.syncthing.net/t/raspberry-pi-some-receive-only-files-always-get-marked-as-local-additions/16246

There is already a mechanism that deals with any filesystem that does not have nano-second precision: The mtimeFS. Meaning that covers the 2s precision of FAT. That mechanism requires though, that the filesystem is consistent: If it told Syncthing at some point that the mod. time of a file is 01:30:03, when asked again it should say 01:30:03 as well - not 01:30:02. And that’s what a “normal” FAT filesystem does. Android on the other hand puts some virtual filesystem shenanigans on top of FAT, and apparently that changes reported mod. times upon restart (well remount probably). And that’s the problem and that’s why the mod. time window workaround is necessary despite having the mtimeFS.

1 Like

Thank you for the explanation, but what is the deal with that Raspberry Pi then though?

No idea. Looking at that thread I don’t think it has even been established whether modification time is the culprit or not.

1 Like

what is mtimeFS? it’s not config options… I’m asking because I got weird sync issues when running syncthing on a rather exotic platforms (a Kobo reader, which runs a custom Linux OS, with a folder backed by a FAT filesystem). I would get spurious sync conflicts, and difficulty propagating file deletions to the device, along with extremely long syncs (10m for a ~16GB folder).

All those issues seem to have gone away after flipping modTimeWindowS from 0 to 2, which wasn’t done automatically even if the backing folder was on a FAT filesystem…

It seems like not only Android has those problems, maybe it would be better to just do this on all FAT filesystems?

I somehow doubt that linux distro does something weird with FAT, but if you’re interested, i could look a little further. Maybe it’s some mount option we’re tripping over?

For what it’s worth, the mount looks like this:

/dev/mmcblk0p3 on /mnt/onboard type vfat (rw,noatime,nodiratime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro)

any specific test i could do to confirm i’m seeing the same behavior Android is?

I think it’s more that it’s not detectable in the general case, at least not easily, and Android is a known environment. Setting the modtimeWindow when you know the fs is FAT is the correct thing.