mirror of
https://github.com/stashapp/stash.git
synced 2026-03-26 15:11:32 +01:00
Merge 3a73d596c2 into fd480c5a3e
This commit is contained in:
commit
535a2d7dbf
1 changed files with 27 additions and 0 deletions
|
|
@ -313,9 +313,36 @@ func (j *CleanGeneratedJob) cleanBlobFiles(ctx context.Context, progress *job.Pr
|
|||
return err
|
||||
}
|
||||
|
||||
// remove empty hash prefix subdirectories
|
||||
j.removeEmptyDirs(j.Paths.Blobs)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (j *CleanGeneratedJob) removeEmptyDirs(root string) {
|
||||
entries, err := os.ReadDir(root)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if !entry.IsDir() {
|
||||
continue
|
||||
}
|
||||
|
||||
dirPath := filepath.Join(root, entry.Name())
|
||||
subEntries, err := os.ReadDir(dirPath)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(subEntries) == 0 {
|
||||
j.logDelete("removing empty directory: %s", entry.Name())
|
||||
j.deleteDir(dirPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (j *CleanGeneratedJob) getScenesWithHash(ctx context.Context, hash string) ([]*models.Scene, error) {
|
||||
fp := models.Fingerprint{
|
||||
Fingerprint: hash,
|
||||
|
|
|
|||
Loading…
Reference in a new issue