From cbfd9e82b714a38ed48fbc6121846ad537af991e Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Tue, 3 Nov 2020 09:34:53 +1100 Subject: [PATCH] Fix image clean (#913) * Use correct regex when cleaning images * Clarify video exclusion pattern heading --- pkg/manager/task_clean.go | 23 +++++++++++++------ .../Settings/SettingsConfigurationPanel.tsx | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/pkg/manager/task_clean.go b/pkg/manager/task_clean.go index 43ec3772a..8f51a64e5 100644 --- a/pkg/manager/task_clean.go +++ b/pkg/manager/task_clean.go @@ -41,13 +41,7 @@ func (t *CleanTask) shouldClean(path string) bool { // use image.FileExists for zip file checking fileExists := image.FileExists(path) - if fileExists && t.getStashFromPath(path) != nil { - logger.Debugf("File Found: %s", path) - if matchFile(path, config.GetExcludes()) { - logger.Infof("File matched regex. Cleaning: \"%s\"", path) - return true - } - } else { + if !fileExists || t.getStashFromPath(path) == nil { logger.Infof("File not found. Cleaning: \"%s\"", path) return true } @@ -71,6 +65,11 @@ func (t *CleanTask) shouldCleanScene(s *models.Scene) bool { return true } + if matchFile(s.Path, config.GetExcludes()) { + logger.Infof("File matched regex. Cleaning: \"%s\"", s.Path) + return true + } + return false } @@ -96,6 +95,11 @@ func (t *CleanTask) shouldCleanGallery(g *models.Gallery) bool { return true } + if matchFile(path, config.GetImageExcludes()) { + logger.Infof("File matched regex. Cleaning: \"%s\"", path) + return true + } + if countImagesInZip(path) == 0 { logger.Infof("Gallery has 0 images. Cleaning: \"%s\"", path) return true @@ -120,6 +124,11 @@ func (t *CleanTask) shouldCleanImage(s *models.Image) bool { return true } + if matchFile(s.Path, config.GetImageExcludes()) { + logger.Infof("File matched regex. Cleaning: \"%s\"", s.Path) + return true + } + return false } diff --git a/ui/v2.5/src/components/Settings/SettingsConfigurationPanel.tsx b/ui/v2.5/src/components/Settings/SettingsConfigurationPanel.tsx index 1de60ed8e..336d375fa 100644 --- a/ui/v2.5/src/components/Settings/SettingsConfigurationPanel.tsx +++ b/ui/v2.5/src/components/Settings/SettingsConfigurationPanel.tsx @@ -423,7 +423,7 @@ export const SettingsConfigurationPanel: React.FC = () => { -
Excluded Patterns
+
Excluded Video Patterns
Regexps of video files/paths to exclude from Scan and add to Clean