basicfs_fileinfo_linuxish.go 965 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright (C) 2022 The Syncthing Authors.
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this file,
  5. // You can obtain one at https://mozilla.org/MPL/2.0/.
  6. //go:build aix || dragonfly || linux || openbsd || solaris || illumos
  7. // +build aix dragonfly linux openbsd solaris illumos
  8. package fs
  9. import (
  10. "syscall"
  11. "time"
  12. "github.com/syncthing/syncthing/lib/build"
  13. )
  14. func (fi basicFileInfo) InodeChangeTime() time.Time {
  15. // On Android, mtime and inode-change-time fluctuate, which can cause
  16. // conflicts even when nothing has been modified on the device itself.
  17. // Ref: https://forum.syncthing.net/t/keep-getting-conflicts-generated-on-android-device-for-files-modified-only-on-a-desktop-pc/19060
  18. if build.IsAndroid {
  19. return time.Time{}
  20. }
  21. if sys, ok := fi.FileInfo.Sys().(*syscall.Stat_t); ok {
  22. return time.Unix(0, sys.Ctim.Nano())
  23. }
  24. return time.Time{}
  25. }