all: Check files on disk/in db when deleting/renaming (fixes #5194) (#5195)

This commit is contained in:
Simon Frei
2018-09-16 09:48:14 +02:00
committed by Jakob Borg
parent 84494edab4
commit c8652222ef
6 changed files with 385 additions and 45 deletions

View File

@@ -610,3 +610,26 @@ type noCurrentFiler struct{}
func (noCurrentFiler) CurrentFile(name string) (protocol.FileInfo, bool) {
return protocol.FileInfo{}, false
}
func CreateFileInfo(fi fs.FileInfo, name string, filesystem fs.Filesystem) (protocol.FileInfo, error) {
f := protocol.FileInfo{
Name: name,
Type: protocol.FileInfoTypeFile,
Permissions: uint32(fi.Mode()),
ModifiedS: fi.ModTime().Unix(),
ModifiedNs: int32(fi.ModTime().Nanosecond()),
Size: fi.Size(),
}
switch {
case fi.IsDir():
f.Type = protocol.FileInfoTypeDirectory
case fi.IsSymlink():
f.Type = protocol.FileInfoTypeSymlink
target, err := filesystem.ReadSymlink(name)
if err != nil {
return protocol.FileInfo{}, err
}
f.SymlinkTarget = target
}
return f, nil
}