From c688aeb0aa5e0795824e19be84c9fa7fe983a77c Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Wed, 12 Oct 2022 18:50:18 -0500 Subject: [PATCH] Do not update message or finish the download until the file is fully renamed --- .../eu/siacs/conversations/http/HttpDownloadConnection.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java index 13d10a7a1d921e89e4111ad42c334ef282ad5df8..e7a0a35373372c57f6e800778f846bf3b45afb3d 100644 --- a/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java +++ b/src/main/java/eu/siacs/conversations/http/HttpDownloadConnection.java @@ -186,8 +186,6 @@ public class HttpDownloadConnection implements Transferable { } private void finish() { - message.setTransferable(null); - mHttpConnectionManager.finishConnection(this); boolean notify = acceptedAutomatically && !message.isRead(); if (message.getEncryption() == Message.ENCRYPTION_PGP) { notify = message.getConversation().getAccount().getPgpDecryptionService().decrypt(message, notify); @@ -202,7 +200,9 @@ public class HttpDownloadConnection implements Transferable { } catch (final IOException e) { file = tmp; } + message.setTransferable(null); mXmppConnectionService.updateMessage(message); + mHttpConnectionManager.finishConnection(this); final boolean notifyAfterScan = notify; mXmppConnectionService.getFileBackend().updateMediaScanner(file, () -> { if (notifyAfterScan) { @@ -381,8 +381,8 @@ public class HttpDownloadConnection implements Transferable { changeStatus(STATUS_DOWNLOADING); download(); decryptIfNeeded(); - updateImageBounds(); finish(); + updateImageBounds(); } catch (final SSLHandshakeException e) { changeStatus(STATUS_OFFER); } catch (final Exception e) {