Fix image exclusion pattern applying to all files (#3241)

* Add debug logging for scanning ignored files
* Fix image exclusion pattern handling
This commit is contained in:
WithoutPants 2022-12-06 12:28:16 +11:00 committed by GitHub
parent dc875ed5d7
commit 38d6af8b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -268,6 +268,7 @@ func (f *scanFilter) Accept(ctx context.Context, path string, info fs.FileInfo)
}
if !info.IsDir() && !isVideoFile && !isImageFile && !isZipFile {
logger.Debugf("Skipping %s as it does not match any known file extensions", path)
return false
}
@ -280,6 +281,7 @@ func (f *scanFilter) Accept(ctx context.Context, path string, info fs.FileInfo)
s := getStashFromDirPath(f.stashPaths, path)
if s == nil {
logger.Debugf("Skipping %s as it is not in the stash library", path)
return false
}
@ -287,12 +289,15 @@ func (f *scanFilter) Accept(ctx context.Context, path string, info fs.FileInfo)
// add a trailing separator so that it correctly matches against patterns like path/.*
pathExcludeTest := path + string(filepath.Separator)
if (s.ExcludeVideo || matchFileRegex(pathExcludeTest, f.videoExcludeRegex)) && (s.ExcludeImage || matchFileRegex(pathExcludeTest, f.imageExcludeRegex)) {
logger.Debugf("Skipping directory %s as it matches video and image exclusion patterns", path)
return false
}
if isVideoFile && (s.ExcludeVideo || matchFileRegex(path, f.videoExcludeRegex)) {
logger.Debugf("Skipping %s as it matches video exclusion patterns", path)
return false
} else if (isImageFile || isZipFile) && s.ExcludeImage || matchFileRegex(path, f.imageExcludeRegex) {
} else if (isImageFile || isZipFile) && (s.ExcludeImage || matchFileRegex(path, f.imageExcludeRegex)) {
logger.Debugf("Skipping %s as it matches image exclusion patterns", path)
return false
}

View File

@ -9,4 +9,5 @@
* Changed performer aliases to be a list, rather than a string field. ([#3113](https://github.com/stashapp/stash/pull/3113))
### 🐛 Bug fixes
* Fixed image exclusion pattern being applied to all files. ([#3241](https://github.com/stashapp/stash/pull/3241))
* Fixed missing captions not being removed during scan. ([#3240](https://github.com/stashapp/stash/pull/3240))