1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 16:28:12 -07:00

For a rerun if no files found in the directory being md5'ed.

This commit is contained in:
Cedric Beust 2016-01-01 10:42:21 -08:00
parent 4568f2f659
commit 2032cd2724
2 changed files with 13 additions and 3 deletions

View file

@ -104,7 +104,8 @@ class IncrementalManager(val fileName: String = IncrementalManager.BUILD_INFO_FI
saveInputChecksum(taskName, it)
logIncremental(1, " input checksum \"$it\" saved")
}
taskOutputChecksum?.let {
// Important to rerun the checksum here since the output of the task might have changed it
iit.outputChecksum()?.let {
saveOutputChecksum(taskName, it)
logIncremental(1, " output checksum \"$it\" saved")
}

View file

@ -22,10 +22,12 @@ public class Md5 {
val ds = directories.filter { it.exists() }
if (ds.size > 0) {
MessageDigest.getInstance("MD5").let { md5 ->
var fileCount = 0
directories.filter { it.exists() }.forEach { file ->
if (file.isFile) {
val bytes = file.readBytes()
md5.update(bytes, 0, bytes.size)
fileCount++
} else {
val files = KFiles.findRecursively(file) // , { f -> f.endsWith("java")})
log(2, " Calculating checksum of ${files.size} files in $file")
@ -34,13 +36,20 @@ public class Md5 {
}.filter {
it.isFile
}.forEach {
fileCount++
val bytes = it.readBytes()
md5.update(bytes, 0, bytes.size)
}
}
}
val result = DatatypeConverter.printHexBinary(md5.digest()).toLowerCase()
return result
// The output directory might exist but with no files in it, in which case
// we must run the task
if (fileCount > 0) {
val result = DatatypeConverter.printHexBinary(md5.digest()).toLowerCase()
return result
} else {
return null
}
}
} else {
return null