mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 07:11:08 +00:00
Merge pull request #1861 from calmh/fix-1860
Be more lenient against errors when deleting (fixes #1860)
This commit is contained in:
commit
3a203b8d83
@ -631,8 +631,16 @@ func (p *rwFolder) deleteDir(file protocol.FileInfo) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err = osutil.InWritableDir(osutil.Remove, realName)
|
err = osutil.InWritableDir(osutil.Remove, realName)
|
||||||
if err == nil || os.IsNotExist(err) {
|
if err == nil || os.IsNotExist(err) {
|
||||||
|
// It was removed or it doesn't exist to start with
|
||||||
|
p.dbUpdates <- file
|
||||||
|
} else if _, err = os.Lstat(realName); err != nil && !os.IsPermission(err) {
|
||||||
|
// We get an error just looking at the directory, and it's not a
|
||||||
|
// permission problem. Lets assume the error is in fact some variant
|
||||||
|
// of "file does not exist" (possibly expressed as some parent being a
|
||||||
|
// file and not a directory etc) and that the delete is handled.
|
||||||
p.dbUpdates <- file
|
p.dbUpdates <- file
|
||||||
} else {
|
} else {
|
||||||
l.Infof("Puller (folder %q, dir %q): delete: %v", p.folder, file.Name, err)
|
l.Infof("Puller (folder %q, dir %q): delete: %v", p.folder, file.Name, err)
|
||||||
@ -673,10 +681,17 @@ func (p *rwFolder) deleteFile(file protocol.FileInfo) {
|
|||||||
err = osutil.InWritableDir(osutil.Remove, realName)
|
err = osutil.InWritableDir(osutil.Remove, realName)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err == nil || os.IsNotExist(err) {
|
||||||
l.Infof("Puller (folder %q, file %q): delete: %v", p.folder, file.Name, err)
|
// It was removed or it doesn't exist to start with
|
||||||
} else {
|
|
||||||
p.dbUpdates <- file
|
p.dbUpdates <- file
|
||||||
|
} else if _, err := os.Lstat(realName); err != nil && !os.IsPermission(err) {
|
||||||
|
// We get an error just looking at the file, and it's not a permission
|
||||||
|
// problem. Lets assume the error is in fact some variant of "file
|
||||||
|
// does not exist" (possibly expressed as some parent being a file and
|
||||||
|
// not a directory etc) and that the delete is handled.
|
||||||
|
p.dbUpdates <- file
|
||||||
|
} else {
|
||||||
|
l.Infof("Puller (folder %q, file %q): delete: %v", p.folder, file.Name, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user