mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
Selective scan (#940)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user