mirror of
https://github.com/stashapp/stash.git
synced 2025-12-16 20:07:05 +03:00
Fix invalid share causing error during cleaning (#4570)
This commit is contained in:
@@ -318,11 +318,22 @@ func (j *cleanJob) flagFolderForDelete(ctx context.Context, toDelete *deleteSet,
|
|||||||
return nil
|
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 {
|
func (j *cleanJob) shouldClean(ctx context.Context, f models.File) bool {
|
||||||
path := f.Base().Path
|
path := f.Base().Path
|
||||||
|
|
||||||
info, err := f.Base().Info(j.FS)
|
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)
|
logger.Errorf("error getting file info for %q, not cleaning: %v", path, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -344,9 +355,8 @@ func (j *cleanJob) shouldCleanFolder(ctx context.Context, f *models.Folder) bool
|
|||||||
path := f.Path
|
path := f.Path
|
||||||
|
|
||||||
info, err := f.Info(j.FS)
|
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 && !isNotFound(err) {
|
||||||
if err != nil && !errors.Is(err, fs.ErrNotExist) && !errors.Is(err, fs.ErrInvalid) {
|
|
||||||
logger.Errorf("error getting folder info for %q, not cleaning: %v", path, err)
|
logger.Errorf("error getting folder info for %q, not cleaning: %v", path, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -367,7 +377,7 @@ func (j *cleanJob) shouldCleanFolder(ctx context.Context, f *models.Folder) bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
info, err = j.FS.Lstat(finalPath)
|
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)
|
logger.Errorf("error getting file info for %q (-> %s), not cleaning: %v", path, finalPath, err)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user