Don't do a file listing if no patterns are defined

This commit is contained in:
Ingo Oppermann 2024-07-16 14:40:45 +02:00
parent 96f7d8030c
commit de1c42e969
No known key found for this signature in database
GPG Key ID: 2AB32426E9DD229E

View File

@ -149,6 +149,14 @@ func (rfs *filesystem) UnsetCleanup(id string) {
}
func (rfs *filesystem) cleanup() {
rfs.cleanupLock.RLock()
nPatterns := len(rfs.cleanupPatterns)
rfs.cleanupLock.RUnlock()
if nPatterns == 0 {
return
}
filesAndDirs := rfs.Filesystem.List("/", fs.ListOptions{})
sort.SliceStable(filesAndDirs, func(i, j int) bool { return filesAndDirs[i].ModTime().Before(filesAndDirs[j].ModTime()) })