Skip to content

Commit

Permalink
export: create tmp file, copy tmp file to destination, remove tmp file
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Aug 26, 2024
1 parent 817314a commit 3544ad4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3095,10 +3095,13 @@ public void eadExport() {
log.error(e);
}
}

Path downloadFile = Paths.get(exportFolder, databaseName.replace(" ", "_"));
try {
outputter.output(document, Files.newOutputStream(downloadFile));
// export into temporary file, copy temp file to destination, remove temp file
Path downloadFile = Paths.get(exportFolder, databaseName.replace(" ", "_"));
Path tempFile = StorageProvider.getInstance().createTemporaryFile(databaseName.replace(" ", "_"), "xml");
outputter.output(document, Files.newOutputStream(tempFile));
StorageProvider.getInstance().copyFile(tempFile, downloadFile);
StorageProvider.getInstance().deleteFile(tempFile);
} catch (IOException e) {
log.error(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,12 @@ public void execute() {
}
}

Path downloadFile = Paths.get(exportFolder, file.replace(" ", "_"));
try {
outputter.output(document, Files.newOutputStream(downloadFile));
Path downloadFile = Paths.get(exportFolder, file.replace(" ", "_"));
Path tempFile = StorageProvider.getInstance().createTemporaryFile(file.replace(" ", "_"), "xml");
outputter.output(document, Files.newOutputStream(tempFile));
StorageProvider.getInstance().copyFile(tempFile, downloadFile);
StorageProvider.getInstance().deleteFile(tempFile);
} catch (IOException e) {
log.error(e);
}
Expand Down

0 comments on commit 3544ad4

Please sign in to comment.