From 16ae1fbe5e77b682aff1c546fe20bf3904cd42df Mon Sep 17 00:00:00 2001 From: tomasz1986 Date: Sat, 21 Oct 2023 08:24:29 +0200 Subject: [PATCH] lib/fs: Ignore inode change time on Android (#9177) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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] 6cac308bcdf197f4bbe8bd36725d9ac92a622559 Signed-off-by: Tomasz WilczyƄski --- lib/fs/basicfs_fileinfo_linuxish.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/fs/basicfs_fileinfo_linuxish.go b/lib/fs/basicfs_fileinfo_linuxish.go index f7de9e49e..737578175 100644 --- a/lib/fs/basicfs_fileinfo_linuxish.go +++ b/lib/fs/basicfs_fileinfo_linuxish.go @@ -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()) }