mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-23 03:18:59 +00:00
16ae1fbe5e
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>
31 lines
965 B
Go
31 lines
965 B
Go
// Copyright (C) 2022 The Syncthing Authors.
|
|
//
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
|
|
//go:build aix || dragonfly || linux || openbsd || solaris || illumos
|
|
// +build aix dragonfly linux openbsd solaris illumos
|
|
|
|
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())
|
|
}
|
|
return time.Time{}
|
|
}
|