Fix invalid share causing error during cleaning (#4570)

This commit is contained in:
WithoutPants 2024-02-19 10:24:10 +11:00 committed by GitHub
parent 6e9718a600
commit e7f610ce18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 5 deletions

View File

@ -318,11 +318,22 @@ func (j *cleanJob) flagFolderForDelete(ctx context.Context, toDelete *deleteSet,
return nil
}
func isNotFound(err error) bool {
// ErrInvalid can occur in zip files where the zip file path changed
// and the underlying folder did not
// #3877 - fs.PathError can occur if the network share no longer exists
var pathErr *fs.PathError
return err != nil &&
(errors.Is(err, fs.ErrNotExist) ||
!errors.Is(err, fs.ErrInvalid) ||
!errors.As(err, &pathErr))
}
func (j *cleanJob) shouldClean(ctx context.Context, f models.File) bool {
path := f.Base().Path
info, err := f.Base().Info(j.FS)
if err != nil && !errors.Is(err, fs.ErrNotExist) {
if err != nil && !isNotFound(err) {
logger.Errorf("error getting file info for %q, not cleaning: %v", path, err)
return false
}
@ -344,9 +355,8 @@ func (j *cleanJob) shouldCleanFolder(ctx context.Context, f *models.Folder) bool
path := f.Path
info, err := f.Info(j.FS)
// ErrInvalid can occur in zip files where the zip file path changed
// and the underlying folder did not
if err != nil && !errors.Is(err, fs.ErrNotExist) && !errors.Is(err, fs.ErrInvalid) {
if err != nil && !isNotFound(err) {
logger.Errorf("error getting folder info for %q, not cleaning: %v", path, err)
return false
}
@ -367,7 +377,7 @@ func (j *cleanJob) shouldCleanFolder(ctx context.Context, f *models.Folder) bool
}
info, err = j.FS.Lstat(finalPath)
if err != nil {
if err != nil && !isNotFound(err) {
logger.Errorf("error getting file info for %q (-> %s), not cleaning: %v", path, finalPath, err)
return false
}