From cae124d93fd5e55d6d92a83c632fd1b2687c3fed Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Fri, 20 Dec 2019 19:07:31 +0100 Subject: [PATCH] createOutputStream(): allow to disable decryption --- .../services/AbstractConnectionManager.java | 13 ++----------- .../conversations/xmpp/jingle/JingleConnection.java | 2 +- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java index 43c28b854..81f3f80bc 100644 --- a/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java +++ b/src/main/java/eu/siacs/conversations/services/AbstractConnectionManager.java @@ -53,20 +53,11 @@ public class AbstractConnectionManager { } } - - public static OutputStream createAppendedOutputStream(DownloadableFile file) { - return createOutputStream(file, true); - } - - public static OutputStream createOutputStream(DownloadableFile file) { - return createOutputStream(file, false); - } - - private static OutputStream createOutputStream(DownloadableFile file, boolean append) { + public static OutputStream createOutputStream(DownloadableFile file, boolean append, boolean decrypt) { FileOutputStream os; try { os = new FileOutputStream(file, append); - if (file.getKey() == null) { + if (file.getKey() == null || !decrypt) { return os; } } catch (FileNotFoundException e) { diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java index 2596f9960..3b2909cc7 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/JingleConnection.java @@ -213,7 +213,7 @@ public class JingleConnection implements Transferable { } this.file.getParentFile().mkdirs(); this.file.createNewFile(); - this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file); + this.mFileOutputStream = AbstractConnectionManager.createOutputStream(this.file, false, true); return this.mFileOutputStream; }