mirror of
https://github.com/octoleo/syncthing.git
synced 2025-04-03 08:11:50 +00:00
lib/scanner: Record inode change time for directories and symlinks (#9250)
This commit is contained in:
parent
7b1932d64e
commit
d51760f410
@ -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)
|
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() {
|
if fi.IsSymlink() {
|
||||||
f.Type = protocol.FileInfoTypeSymlink
|
f.Type = protocol.FileInfoTypeSymlink
|
||||||
target, err := filesystem.ReadSymlink(name)
|
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
|
f.NoPermissions = true // Symlinks don't have permissions of their own
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Permissions = uint32(fi.Mode() & fs.ModePerm)
|
f.Permissions = uint32(fi.Mode() & fs.ModePerm)
|
||||||
f.ModifiedS = fi.ModTime().Unix()
|
f.ModifiedS = fi.ModTime().Unix()
|
||||||
f.ModifiedNs = fi.ModTime().Nanosecond()
|
f.ModifiedNs = fi.ModTime().Nanosecond()
|
||||||
|
|
||||||
if fi.IsDir() {
|
if fi.IsDir() {
|
||||||
f.Type = protocol.FileInfoTypeDirectory
|
f.Type = protocol.FileInfoTypeDirectory
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
f.Size = fi.Size()
|
f.Size = fi.Size()
|
||||||
f.Type = protocol.FileInfoTypeFile
|
f.Type = protocol.FileInfoTypeFile
|
||||||
if ct := fi.InodeChangeTime(); !ct.IsZero() {
|
|
||||||
f.InodeChangeNs = ct.UnixNano()
|
|
||||||
} else {
|
|
||||||
f.InodeChangeNs = 0
|
|
||||||
}
|
|
||||||
return f, nil
|
return f, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user