* improve --def deleteAfterExtract=y logic
This commit is contained in:
parent
49bb8f8395
commit
bf04656860
|
@ -92,23 +92,18 @@ 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
|
||||||
|
def extractedArchives = []
|
||||||
def tempFiles = []
|
def tempFiles = []
|
||||||
input = input.flatten{ f ->
|
input = input.flatten{ f ->
|
||||||
if (f.isArchive() || f.hasExtension('001')) {
|
if (f.isArchive() || f.hasExtension('001')) {
|
||||||
def extractDir = new File(f.dir, f.nameWithoutExtension)
|
def extractDir = new File(f.dir, f.nameWithoutExtension)
|
||||||
def extractFiles = extract(file: f, output: new File(extractDir, f.dir.name), conflict: 'skip', filter: { it.isArchive() || it.isVideo() || it.isSubtitle() || (music && it.isAudio()) }, forceExtractAll: true) ?: []
|
def extractFiles = extract(file: f, output: new File(extractDir, f.dir.name), conflict: 'skip', filter: { it.isArchive() || it.isVideo() || it.isSubtitle() || (music && it.isAudio()) }, forceExtractAll: true) ?: []
|
||||||
|
|
||||||
|
if (extractFiles.size() > 0) {
|
||||||
|
extractedArchives += f
|
||||||
tempFiles += extractDir
|
tempFiles += extractDir
|
||||||
tempFiles += extractFiles
|
tempFiles += extractFiles
|
||||||
|
|
||||||
if (deleteAfterExtract) {
|
|
||||||
_log.finest("Mark archive for deletion: $f")
|
|
||||||
f.deleteOnExit()
|
|
||||||
f.dir.listFiles().toList().findAll{ v -> v.name.startsWith(f.nameWithoutExtension) && v.extension ==~ /r\d+/ }.each{ v ->
|
|
||||||
_log.finest("Mark volume for deletion: $v")
|
|
||||||
v.deleteOnExit()
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return extractFiles
|
return extractFiles
|
||||||
}
|
}
|
||||||
return f
|
return f
|
||||||
|
@ -347,6 +342,17 @@ if (gmail) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (deleteAfterExtract) {
|
||||||
|
extractedArchives.each{ a ->
|
||||||
|
_log.finest("Delete archive $a")
|
||||||
|
a.delete()
|
||||||
|
a.dir.listFiles().toList().findAll{ v -> v.name.startsWith(a.nameWithoutExtension) && v.extension ==~ /r\d+/ }.each{ v ->
|
||||||
|
_log.finest("Delete archive volume $v")
|
||||||
|
v.delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// clean empty folders, clutter files, etc after move
|
// clean empty folders, clutter files, etc after move
|
||||||
if (clean) {
|
if (clean) {
|
||||||
if (['COPY', 'HARDLINK'].find{ it.equalsIgnoreCase(_args.action) } && tempFiles.size() > 0) {
|
if (['COPY', 'HARDLINK'].find{ it.equalsIgnoreCase(_args.action) } && tempFiles.size() > 0) {
|
||||||
|
|
Loading…
Reference in New Issue