Handle folder symlinks correctly during clean (#3415)

This commit is contained in:
WithoutPants 2023-02-11 09:21:18 +11:00 committed by GitHub
parent f0988817c8
commit 3cf97f6e27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -5,6 +5,8 @@ import (
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"github.com/stashapp/stash/pkg/job"
"github.com/stashapp/stash/pkg/logger"
@ -351,6 +353,22 @@ func (j *cleanJob) shouldCleanFolder(ctx context.Context, f *Folder) bool {
return true
}
// #3261 - handle symlinks
if info.Mode()&os.ModeSymlink == os.ModeSymlink {
finalPath, err := filepath.EvalSymlinks(path)
if err != nil {
// don't bail out if symlink is invalid
logger.Infof("Invalid symlink. Marking to clean: \"%s\"", path)
return true
}
info, err = j.FS.Lstat(finalPath)
if err != nil {
logger.Errorf("error getting file info for %q (-> %s), not cleaning: %v", path, finalPath, err)
return false
}
}
// run through path filter, if returns false then the file should be cleaned
filter := j.options.PathFilter

View File

@ -14,6 +14,7 @@
* Changed performer aliases to be a list, rather than a string field. ([#3113](https://github.com/stashapp/stash/pull/3113))
### 🐛 Bug fixes
* Fixed folder symlinks not being handled correctly during clean. ([#3415](https://github.com/stashapp/stash/pull/3415))
* Fixed error when clicking Scrape All when a file-less scene is in the scene list. ([#3414](https://github.com/stashapp/stash/pull/3414))
* Fixed clicking popover pills not clearing search term. ([#3408](https://github.com/stashapp/stash/pull/3408))
* Fixed URL not being preserved when redirected to login. ([#3305](https://github.com/stashapp/stash/pull/3305))