don’t mark pgp encrypted files received from dino as deleted

This commit is contained in:
Daniel Gultsch 2019-10-11 15:37:41 +02:00
parent ddffe198c6
commit e0b5010f24
2 changed files with 12 additions and 0 deletions

View file

@ -201,6 +201,9 @@ public class PgpDecryptionService {
if (fixedFile.getParentFile().mkdirs()) { if (fixedFile.getParentFile().mkdirs()) {
Log.d(Config.LOGTAG,"created parent directories for "+fixedFile.getAbsolutePath()); 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)) { if (outputFile.renameTo(fixedFile)) {
Log.d(Config.LOGTAG, "renamed " + outputFile.getAbsolutePath() + " to " + fixedFile.getAbsolutePath()); Log.d(Config.LOGTAG, "renamed " + outputFile.getAbsolutePath() + " to " + fixedFile.getAbsolutePath());
message.setRelativeFilePath(path); message.setRelativeFilePath(path);

View file

@ -277,6 +277,9 @@ public class XmppConnectionService extends Service {
private final Object LISTENER_LOCK = new Object(); private final Object LISTENER_LOCK = new Object();
public final Set<String> FILENAMES_TO_IGNORE_DELETION = new HashSet<>();
private final OnBindListener mOnBindListener = new OnBindListener() { private final OnBindListener mOnBindListener = new OnBindListener() {
@Override @Override
@ -1831,6 +1834,12 @@ public class XmppConnectionService extends Service {
} }
private void markFileDeleted(final String path) { 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 File file = new File(path);
final boolean isInternalFile = fileBackend.isInternalFile(file); final boolean isInternalFile = fileBackend.isInternalFile(file);
final List<String> uuids = databaseBackend.markFileAsDeleted(file, isInternalFile); final List<String> uuids = databaseBackend.markFileAsDeleted(file, isInternalFile);