From cfba793fcfa09d59fb6d5effbd8b4ee3739f219a Mon Sep 17 00:00:00 2001 From: CalDescent Date: Sat, 14 Aug 2021 18:10:59 +0100 Subject: [PATCH] Fixed bugs in ArbitraryDataFile, introduced when switching to the new temporary path. --- .../java/org/qortal/arbitrary/ArbitraryDataFile.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/qortal/arbitrary/ArbitraryDataFile.java b/src/main/java/org/qortal/arbitrary/ArbitraryDataFile.java index ecc3e147..55aafc60 100644 --- a/src/main/java/org/qortal/arbitrary/ArbitraryDataFile.java +++ b/src/main/java/org/qortal/arbitrary/ArbitraryDataFile.java @@ -264,16 +264,16 @@ public class ArbitraryDataFile { // Create temporary path for joined file // Use the user-specified temp dir, as it is deterministic, and is more likely to be located on reusable storage hardware String baseDir = Settings.getInstance().getTempDataPath(); - Path tempDir = Paths.get(baseDir, "join", this.chunks.get(0).digest58()); + Path tempDir = Paths.get(baseDir, "join"); try { Files.createDirectories(tempDir); } catch (IOException e) { return false; } - this.filePath = tempDir.toString(); // Join the chunks - File outputFile = new File(this.filePath); + Path outputPath = Paths.get(tempDir.toString(), this.chunks.get(0).digest58()); + File outputFile = new File(outputPath.toString()); try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) { for (ArbitraryDataFileChunk chunk : this.chunks) { File sourceFile = new File(chunk.filePath); @@ -288,9 +288,9 @@ public class ArbitraryDataFile { out.close(); // Copy temporary file to data directory - this.filePath = this.copyToDataDirectory(tempDir); - if (FilesystemUtils.pathInsideDataOrTempPath(tempDir)) { - Files.delete(tempDir); + this.filePath = this.copyToDataDirectory(outputPath); + if (FilesystemUtils.pathInsideDataOrTempPath(outputPath)) { + Files.delete(outputPath); } return true;