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

GH-423: Overwrite files on Windows too.

Fixes https://github.com/cbeust/kobalt/issues/423
This commit is contained in:
Cedric Beust 2017-04-21 23:02:59 -07:00
parent c768507ed5
commit cc481a4a7f

View file

@ -227,22 +227,18 @@ class KFiles {
private fun isWindows() = System.getProperty("os.name").contains("Windows") private fun isWindows() = System.getProperty("os.name").contains("Windows")
fun copy(from: Path?, to: Path?, option: StandardCopyOption = StandardCopyOption.REPLACE_EXISTING) { fun copy(from: Path?, to: Path?, option: StandardCopyOption = StandardCopyOption.REPLACE_EXISTING) {
if (isWindows() && to!!.toFile().exists()) { try {
kobaltLog(2, "Windows detected, not overwriting $to") if (from != null && to != null) {
} else { if (!Files.exists(to) || Md5.toMd5(from.toFile()) != Md5.toMd5(to.toFile())) {
try { kobaltLog(3, "Copy from $from to $to")
if (from != null && to != null) { Files.copy(from, to, option)
if (!Files.exists(to) || Md5.toMd5(from.toFile()) != Md5.toMd5(to.toFile())) { } else {
kobaltLog(3, "Copy from $from to $to") kobaltLog(3, " Not copying, indentical files: $from $to")
Files.copy(from, to, option)
} else {
kobaltLog(3, " Not copying, indentical files: $from $to")
}
} }
} catch(ex: IOException) {
// Windows is anal about this
kobaltLog(1, "Couldn't copy $from to $to: ${ex.message}")
} }
} catch(ex: IOException) {
// Windows is anal about this
kobaltLog(1, "Couldn't copy $from to $to: ${ex.message}")
} }
} }