lib/fs: Ignore inode change time on Android (#9177)

lib/fs: Fix conflicts on Android due to fluctuating inode change time

[1] added inode change time to file info in order to support syncing
extended attributes. However, in the case of Android, this inode change
time fluctuates, leading to unexpected conflicts even when the user has
not even touched the files on the Android device itself. Thus, in order
to prevent those conflicts from happening, do not write inode change
time on Android.

[1] 6cac308bcd

Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
This commit is contained in:
tomasz1986 2023-10-21 08:24:29 +02:00 committed by GitHub
parent 11f508d9be
commit 16ae1fbe5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,9 +12,17 @@ package fs
import (
"syscall"
"time"
"github.com/syncthing/syncthing/lib/build"
)
func (fi basicFileInfo) InodeChangeTime() time.Time {
// On Android, mtime and inode-change-time fluctuate, which can cause
// conflicts even when nothing has been modified on the device itself.
// Ref: https://forum.syncthing.net/t/keep-getting-conflicts-generated-on-android-device-for-files-modified-only-on-a-desktop-pc/19060
if build.IsAndroid {
return time.Time{}
}
if sys, ok := fi.FileInfo.Sys().(*syscall.Stat_t); ok {
return time.Unix(0, sys.Ctim.Nano())
}