check if encrypted pgp file get deleted

This commit is contained in:
Daniel Gultsch 2019-01-10 21:24:24 +01:00
parent 8ab4ca7138
commit 7cabb2c377
5 changed files with 1474 additions and 1477 deletions

View File

@ -209,10 +209,10 @@ public class PgpDecryptionService {
URL url = message.getFileParams().url;
mXmppConnectionService.getFileBackend().updateFileParams(message, url);
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
mXmppConnectionService.updateMessage(message);
if (!inputFile.delete()) {
Log.w(Config.LOGTAG,"unable to delete pgp encrypted source file "+inputFile.getAbsolutePath());
}
mXmppConnectionService.updateMessage(message);
skipNotificationPush = true;
mXmppConnectionService.getFileBackend().updateMediaScanner(outputFile, () -> notifyIfPending(message));
break;

View File

@ -179,20 +179,6 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
}
}
public void findMessagesWithFiles(final OnMessageFound onMessageFound) {
final ArrayList<Message> results = new ArrayList<>();
synchronized (this.messages) {
for (final Message m : this.messages) {
if (m.isFileOrImage() && m.getEncryption() != Message.ENCRYPTION_PGP) {
results.add(m);
}
}
}
for(Message result : results) {
onMessageFound.onMessageFound(result);
}
}
public Message findMessageWithFileAndUuid(final String uuid) {
synchronized (this.messages) {
for (final Message message : this.messages) {
@ -208,11 +194,15 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
public boolean markAsDeleted(final List<String> uuids) {
boolean deleted = false;
final PgpDecryptionService pgpDecryptionService = account.getPgpDecryptionService();
synchronized (this.messages) {
for(Message message : this.messages) {
if (uuids.contains(message.getUuid())) {
message.setDeleted(true);
deleted = true;
if (message.getEncryption() == Message.ENCRYPTION_PGP && pgpDecryptionService != null) {
pgpDecryptionService.discard(message);
}
}
}
}

View File

@ -810,8 +810,14 @@ public class DatabaseBackend extends SQLiteOpenHelper {
String selection;
String[] selectionArgs;
if (internal) {
final String name = file.getName();
if (name.endsWith(".pgp")) {
selection = "(" + Message.RELATIVE_FILE_PATH + " IN(?,?) OR (" + Message.RELATIVE_FILE_PATH + "=? and encryption in(1,4))) and type in (1,2)";
selectionArgs = new String[]{file.getAbsolutePath(), name, name.substring(0, name.length() - 4)};
} else {
selection = Message.RELATIVE_FILE_PATH + " IN(?,?) and type in (1,2)";
selectionArgs = new String[]{file.getAbsolutePath(),file.getName()};
selectionArgs = new String[]{file.getAbsolutePath(), name};
}
} else {
selection = Message.RELATIVE_FILE_PATH + "=? and type in (1,2)";
selectionArgs = new String[]{file.getAbsolutePath()};
@ -870,6 +876,7 @@ public class DatabaseBackend extends SQLiteOpenHelper {
public static class FilePath {
public final UUID uuid;
public final String path;
private FilePath(String uuid, String path) {
this.uuid = UUID.fromString(uuid);
this.path = path;

View File

@ -1089,7 +1089,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
copyLink.setVisible(true);
}
}
if (m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED) {
if (m.getEncryption() == Message.ENCRYPTION_DECRYPTION_FAILED && !deleted) {
retryDecryption.setVisible(true);
}
if (!showError