From e0b5010f24d55ca4c973e83fdba33760e9c7a84a Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 11 Oct 2019 15:37:41 +0200 Subject: [PATCH] =?UTF-8?q?don=E2=80=99t=20mark=20pgp=20encrypted=20files?= =?UTF-8?q?=20received=20from=20dino=20as=20deleted?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../siacs/conversations/crypto/PgpDecryptionService.java | 3 +++ .../conversations/services/XmppConnectionService.java | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java b/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java index 2989f356a..29d286a71 100644 --- a/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java +++ b/src/main/java/eu/siacs/conversations/crypto/PgpDecryptionService.java @@ -201,6 +201,9 @@ public class PgpDecryptionService { if (fixedFile.getParentFile().mkdirs()) { Log.d(Config.LOGTAG,"created parent directories for "+fixedFile.getAbsolutePath()); } + synchronized (mXmppConnectionService.FILENAMES_TO_IGNORE_DELETION) { + mXmppConnectionService.FILENAMES_TO_IGNORE_DELETION.add(outputFile.getAbsolutePath()); + } if (outputFile.renameTo(fixedFile)) { Log.d(Config.LOGTAG, "renamed " + outputFile.getAbsolutePath() + " to " + fixedFile.getAbsolutePath()); message.setRelativeFilePath(path); diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 5eef556e2..4400e21a2 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -277,6 +277,9 @@ public class XmppConnectionService extends Service { private final Object LISTENER_LOCK = new Object(); + public final Set FILENAMES_TO_IGNORE_DELETION = new HashSet<>(); + + private final OnBindListener mOnBindListener = new OnBindListener() { @Override @@ -1831,6 +1834,12 @@ public class XmppConnectionService extends Service { } private void markFileDeleted(final String path) { + synchronized (FILENAMES_TO_IGNORE_DELETION) { + if (FILENAMES_TO_IGNORE_DELETION.remove(path)) { + Log.d(Config.LOGTAG,"ignored deletion of "+path); + return; + } + } final File file = new File(path); final boolean isInternalFile = fileBackend.isInternalFile(file); final List uuids = databaseBackend.markFileAsDeleted(file, isInternalFile);