mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-23 08:18:52 -05:00
* performance boost for dealing with large structures
This commit is contained in:
parent
5d30c78dff
commit
99a6eb916e
@ -26,8 +26,11 @@ def clean(f) {
|
||||
}
|
||||
|
||||
|
||||
// memoize media folder status for performance
|
||||
def hasMediaFiles = { dir -> dir.getFiles().find{ (it.isVideo() || it.isAudio()) && !isClutter(it) } }.memoize()
|
||||
|
||||
// delete clutter files in orphaned media folders
|
||||
args.getFiles{ isClutter(it) && !it.dir.getFiles().find{ (it.isVideo() || it.isAudio()) && !isClutter(it) }}.each { clean(it) }
|
||||
args.getFiles{ isClutter(it) && !hasMediaFiles(it.dir) }.each { clean(it) }
|
||||
|
||||
// delete empty folders but exclude given args
|
||||
args.getFolders().sort().reverse().each { if (it.listFiles().length == 0) { if (deleteRootFolder || !args.contains(it)) clean(it) } }
|
||||
|
Loading…
Reference in New Issue
Block a user