Be more lenient against errors when deleting (fixes #1860)

This commit is contained in:
Jakob Borg 2015-05-23 23:55:50 +02:00
parent bccf7fc2a8
commit 29da0bc8f5

View File

@ -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)
} }
} }