forked from Qortal/qortal
Fixed bugs in ArbitraryDataFile, introduced when switching to the new temporary path.
This commit is contained in:
parent
c50a11e58a
commit
cfba793fcf
@ -264,16 +264,16 @@ public class ArbitraryDataFile {
|
|||||||
// Create temporary path for joined file
|
// 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
|
// 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();
|
String baseDir = Settings.getInstance().getTempDataPath();
|
||||||
Path tempDir = Paths.get(baseDir, "join", this.chunks.get(0).digest58());
|
Path tempDir = Paths.get(baseDir, "join");
|
||||||
try {
|
try {
|
||||||
Files.createDirectories(tempDir);
|
Files.createDirectories(tempDir);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.filePath = tempDir.toString();
|
|
||||||
|
|
||||||
// Join the chunks
|
// 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))) {
|
try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) {
|
||||||
for (ArbitraryDataFileChunk chunk : this.chunks) {
|
for (ArbitraryDataFileChunk chunk : this.chunks) {
|
||||||
File sourceFile = new File(chunk.filePath);
|
File sourceFile = new File(chunk.filePath);
|
||||||
@ -288,9 +288,9 @@ public class ArbitraryDataFile {
|
|||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
// Copy temporary file to data directory
|
// Copy temporary file to data directory
|
||||||
this.filePath = this.copyToDataDirectory(tempDir);
|
this.filePath = this.copyToDataDirectory(outputPath);
|
||||||
if (FilesystemUtils.pathInsideDataOrTempPath(tempDir)) {
|
if (FilesystemUtils.pathInsideDataOrTempPath(outputPath)) {
|
||||||
Files.delete(tempDir);
|
Files.delete(outputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user