* support cleaning up temporary extracted files

This commit is contained in:
Reinhard Pointner 2013-01-29 10:32:48 +00:00
parent 75bd998408
commit d22289cb24
1 changed files with 25 additions and 3 deletions

View File

@ -80,7 +80,8 @@ if (args.empty) {
input = input.flatten() input = input.flatten()
// extract archives (zip, rar, etc) that contain at least one video file // extract archives (zip, rar, etc) that contain at least one video file
input += extract(file: input.findAll{ it.isArchive() }, output: null, conflict: 'override', filter: { it.isVideo() || it.isAudio() }, forceExtractAll: true) def extractedFiles = extract(file: input.findAll{ it.isArchive() }, output: null, conflict: 'override', filter: { it.isVideo() || it.isAudio() }, forceExtractAll: true)
input += extractedFiles
// sanitize input // sanitize input
input = input.findAll{ it?.exists() }.collect{ it.canonicalFile }.unique() input = input.findAll{ it?.exists() }.collect{ it.canonicalFile }.unique()
@ -270,6 +271,27 @@ if (gmail) {
// clean empty folders, clutter files, etc after move // clean empty folders, clutter files, etc after move
if (clean) { if (clean) {
println 'Clean clutter files and empty folders' if ('COPY'.equalsIgnoreCase(_args.action) && extractedFiles?.size() > 0) {
include('fn:cleaner', [:], !args.empty ? args : ut_kind == 'multi' && ut_dir ? [ut_dir as File] : []) println 'Clean temporary extracted files'
// delete extracted files
extractedFiles.each{
if(it.isFile()) {
println "Delete $it"
it.delete()
}
}
// delete remaining empty folders
extractedFiles*.dir.unique().findAll{ it.listFiles().length == 0 }.each{
if(it.isDirectory()) {
println "Delete $it"
it.delete()
}
}
}
// deleting remaining files only makes sense after moving files
if ('MOVE'.equalsIgnoreCase(_args.action)) {
println 'Clean clutter files and empty folders'
include('fn:cleaner', [:], !args.empty ? args : ut_kind == 'multi' && ut_dir ? [ut_dir as File] : [])
}
} }