Skip to content

Commit

Permalink
pcorlessGH-46 Saves dav without using temp file
Browse files Browse the repository at this point in the history
  • Loading branch information
gtache committed Aug 17, 2020
1 parent ca79bc8 commit 157a7fd
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3582,15 +3582,15 @@ public void saveFile() {
if (document.getStateManager().hasChangedSince(savedChanges)) {
if (pdfClient != null) {
try {
//TODO no choice but to dump file to append changes as long as IncrementalUpdater is obfuscated
File tmp = Files.createTempFile(pdfClient.getName(), "." + FileExtensionUtils.pdf).toFile();
try (final OutputStream out = new BufferedOutputStream(new FileOutputStream(tmp))) {
document.saveToOutputStream(out);
}
try (final InputStream pdfIn = new BufferedInputStream(new FileInputStream(tmp))) {
pdfClient.save(pdfIn);
}
tmp.delete();
final PipedInputStream in = new PipedInputStream();
new Thread(() -> {
try (final PipedOutputStream out = new PipedOutputStream(in)) {
document.saveToOutputStream(out);
} catch (final IOException e) {
logger.log(Level.WARNING, e, () -> "Error writing to output");
}
}).start();
pdfClient.save(in);
savedChanges = document.getStateManager().getChanges();
} catch (IOException e) {
logger.log(Level.FINE, "IOException while saving dav", e);
Expand Down

0 comments on commit 157a7fd

Please sign in to comment.