Kotlin: Don't fail if a file already exists in the source archive

This commit is contained in:
Ian Lynagh
2021-09-06 13:54:03 +01:00
parent 19ff50d0a6
commit 9bd0391c04

View File

@@ -222,7 +222,11 @@ fun doFile(invocationTrapFile: String, checkTrapIdentical: Boolean, logger: Logg
val dest = Paths.get("$srcDir/${declaration.path}")
val destDir = dest.getParent()
Files.createDirectories(destDir)
Files.copy(Paths.get(declaration.path), dest)
val srcTmpFile = File.createTempFile(dest.getFileName().toString() + ".", ".src.tmp", destDir.toFile())
val srcTmpOS = FileOutputStream(srcTmpFile)
Files.copy(Paths.get(declaration.path), srcTmpOS)
srcTmpOS.close()
srcTmpFile.renameTo(dest.toFile())
val trapFile = File("$trapDir/$filePath.trap")
val trapFileDir = trapFile.getParentFile()