lib/model: More precise deletion detection (fixes #2571, fixes #4573) (#4765)

This commit is contained in:
Simon Frei
2018-02-25 09:27:54 +01:00
committed by Jakob Borg
parent e99be02055
commit 5822222c74
3 changed files with 213 additions and 23 deletions

View File

@@ -153,3 +153,14 @@ func init() {
func IsWindowsExecutable(path string) bool {
return execExts[strings.ToLower(filepath.Ext(path))]
}
func IsDeleted(ffs fs.Filesystem, name string) bool {
if _, err := ffs.Lstat(name); fs.IsNotExist(err) {
return true
}
switch TraversesSymlink(ffs, filepath.Dir(name)).(type) {
case *NotADirectoryError, *TraversesSymlinkError:
return true
}
return false
}