# Why default modTimeWindowS to 2 for FAT only on Android?

**URL:** https://forum.syncthing.net/t/why-default-modtimewindows-to-2-for-fat-only-on-android/16256
**Category:** Development
**Created:** [January 26, 2021, 7:31am UTC](https://forum.syncthing.net/t/why-default-modtimewindows-to-2-for-fat-only-on-android/16256 "2021-01-26T07:31:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![tomasz86](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/t/96bed5/32.png) [@tomasz86](https://forum.syncthing.net/u/tomasz86)
#### Post date: [January 26, 2021, 7:31am UTC](https://forum.syncthing.net/t/why-default-modtimewindows-to-2-for-fat-only-on-android/16256/1 "2021-01-26T07:31:36Z")

</div>

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:

> <https://github.com/syncthing/syncthing/blob/0db3b7a5304c679226687a53af994a0c650e056d/lib/config/folderconfiguration.go#L73-L87>

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

---

<div class="post-metadata">

### Author: ![imsodin](https://forum.syncthing.net/user_avatar/forum.syncthing.net/imsodin/32/3317_2.png) [@imsodin](https://forum.syncthing.net/u/imsodin)
#### Post date: [January 26, 2021, 8:50am UTC](https://forum.syncthing.net/t/why-default-modtimewindows-to-2-for-fat-only-on-android/16256/2 "2021-01-26T08:50:04Z")

</div>

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`.

---

<div class="post-metadata">

### Author: ![tomasz86](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/t/96bed5/32.png) [@tomasz86](https://forum.syncthing.net/u/tomasz86)
#### Post date: [January 26, 2021, 9:07am UTC](https://forum.syncthing.net/t/why-default-modtimewindows-to-2-for-fat-only-on-android/16256/3 "2021-01-26T09:07:00Z")

</div>

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

---

<div class="post-metadata">

### Author: ![imsodin](https://forum.syncthing.net/user_avatar/forum.syncthing.net/imsodin/32/3317_2.png) [@imsodin](https://forum.syncthing.net/u/imsodin)
#### Post date: [January 26, 2021, 9:08am UTC](https://forum.syncthing.net/t/why-default-modtimewindows-to-2-for-fat-only-on-android/16256/4 "2021-01-26T09:08:01Z")

</div>

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

---

<div class="post-metadata">

### Author: ![anarcat](https://forum.syncthing.net/user_avatar/forum.syncthing.net/anarcat/32/4373_2.png) [@anarcat](https://forum.syncthing.net/u/anarcat)
#### Post date: [August 17, 2024, 2:42am UTC](https://forum.syncthing.net/t/why-default-modtimewindows-to-2-for-fat-only-on-android/16256/5 "2024-08-17T02:42:08Z")

</div>

what _is_ `mtimeFS`? it’s not [config options](https://docs.syncthing.net/v1.27.10/users/config)… 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:

```plaintext
/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?

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [August 17, 2024, 5:07am UTC](https://forum.syncthing.net/t/why-default-modtimewindows-to-2-for-fat-only-on-android/16256/6 "2024-08-17T05:07:01Z")

</div>

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.
