Selective scan (#940)

This commit is contained in:
WithoutPants
2020-11-16 09:20:04 +11:00
committed by GitHub
parent ba8b3b29a4
commit 0a098b1d63
12 changed files with 279 additions and 97 deletions

View File

@@ -41,7 +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 {
if !fileExists || getStashFromPath(path) == nil {
logger.Infof("File not found. Cleaning: \"%s\"", path)
return true
}
@@ -54,7 +54,7 @@ func (t *CleanTask) shouldCleanScene(s *models.Scene) bool {
return true
}
stash := t.getStashFromPath(s.Path)
stash := getStashFromPath(s.Path)
if stash.ExcludeVideo {
logger.Infof("File in stash library that excludes video. Cleaning: \"%s\"", s.Path)
return true
@@ -84,7 +84,7 @@ func (t *CleanTask) shouldCleanGallery(g *models.Gallery) bool {
return true
}
stash := t.getStashFromPath(path)
stash := getStashFromPath(path)
if stash.ExcludeImage {
logger.Infof("File in stash library that excludes images. Cleaning: \"%s\"", path)
return true
@@ -113,7 +113,7 @@ func (t *CleanTask) shouldCleanImage(s *models.Image) bool {
return true
}
stash := t.getStashFromPath(s.Path)
stash := getStashFromPath(s.Path)
if stash.ExcludeImage {
logger.Infof("File in stash library that excludes images. Cleaning: \"%s\"", s.Path)
return true
@@ -211,9 +211,8 @@ func (t *CleanTask) fileExists(filename string) (bool, error) {
return !info.IsDir(), nil
}
func (t *CleanTask) getStashFromPath(pathToCheck string) *models.StashConfig {
func getStashFromPath(pathToCheck string) *models.StashConfig {
for _, s := range config.GetStashPaths() {
rel, error := filepath.Rel(s.Path, filepath.Dir(pathToCheck))
if error == nil {
@@ -225,3 +224,17 @@ func (t *CleanTask) getStashFromPath(pathToCheck string) *models.StashConfig {
}
return nil
}
func getStashFromDirPath(pathToCheck string) *models.StashConfig {
for _, s := range config.GetStashPaths() {
rel, error := filepath.Rel(s.Path, pathToCheck)
if error == nil {
if !strings.HasPrefix(rel, ".."+string(filepath.Separator)) {
return s
}
}
}
return nil
}