diff options
author | Jakob Borg <jakob@kastelo.net> | 2023-12-04 07:48:24 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-04 07:48:24 +0100 |
commit | d51760f410577d926601a14d6b8d4c944dfc4be7 (patch) | |
tree | b01b9833751fa97f54a0734d27776224f77707c5 | |
parent | 7b1932d64e1216ef664cdef452b0b4975692c44a (diff) | |
download | syncthing-d51760f410577d926601a14d6b8d4c944dfc4be7.tar.gz syncthing-d51760f410577d926601a14d6b8d4c944dfc4be7.zip |
lib/scanner: Record inode change time for directories and symlinks (#9250)
-rw-r--r-- | lib/scanner/walk.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/scanner/walk.go b/lib/scanner/walk.go index c92427a1f..e971b909c 100644 --- a/lib/scanner/walk.go +++ b/lib/scanner/walk.go @@ -688,6 +688,13 @@ func CreateFileInfo(fi fs.FileInfo, name string, filesystem fs.Filesystem, scanO return protocol.FileInfo{}, fmt.Errorf("reading platform data: %w", err) } } + + if ct := fi.InodeChangeTime(); !ct.IsZero() { + f.InodeChangeNs = ct.UnixNano() + } else { + f.InodeChangeNs = 0 + } + if fi.IsSymlink() { f.Type = protocol.FileInfoTypeSymlink target, err := filesystem.ReadSymlink(name) @@ -698,19 +705,18 @@ func CreateFileInfo(fi fs.FileInfo, name string, filesystem fs.Filesystem, scanO f.NoPermissions = true // Symlinks don't have permissions of their own return f, nil } + f.Permissions = uint32(fi.Mode() & fs.ModePerm) f.ModifiedS = fi.ModTime().Unix() f.ModifiedNs = fi.ModTime().Nanosecond() + if fi.IsDir() { f.Type = protocol.FileInfoTypeDirectory return f, nil } + f.Size = fi.Size() f.Type = protocol.FileInfoTypeFile - if ct := fi.InodeChangeTime(); !ct.IsZero() { - f.InodeChangeNs = ct.UnixNano() - } else { - f.InodeChangeNs = 0 - } + return f, nil } |