Removed temporary target copy on messaged deleted

pull/147/head
M66B 6 years ago
parent b0c1747bbe
commit cb68ddb269

@ -159,6 +159,7 @@ public class EntityOperation {
// Create copy without uid in target folder
// Message with same msgid can be in archive
Long newid = null;
if (message.uid != null &&
message.ui_seen &&
target.synchronize &&
@ -170,7 +171,7 @@ public class EntityOperation {
message.account = target.account;
message.folder = target.id;
message.uid = null;
long newid = db.message().insertMessage(message);
newid = db.message().insertMessage(message);
message.id = id;
message.account = source.account;
message.folder = source.id;
@ -187,13 +188,18 @@ public class EntityOperation {
}
EntityAttachment.copy(context, db, message.id, newid);
// Store new id for when source message was deleted
jargs.put(1, newid);
}
// Cross account move
if (!source.account.equals(target.account)) {
name = ADD;
folder = target.id;
jargs.remove(0);
jargs = new JSONArray();
if (newid != null)
jargs.put(0, newid);
}
} else if (DELETE.equals(name))

@ -1451,6 +1451,8 @@ public class ServiceSynchronize extends LifecycleService {
if (op.message != null)
message = db.message().getMessage(op.message);
JSONArray jargs = new JSONArray(op.args);
try {
if (message == null && !EntityOperation.SYNC.equals(op.name))
throw new MessageRemovedException();
@ -1466,8 +1468,6 @@ public class ServiceSynchronize extends LifecycleService {
EntityOperation.SYNC.equals(op.name)))
throw new IllegalArgumentException(op.name + " without uid " + op.args);
JSONArray jargs = new JSONArray(op.args);
// Operations should use database transaction when needed
if (EntityOperation.SEEN.equals(op.name))
@ -1538,10 +1538,19 @@ public class ServiceSynchronize extends LifecycleService {
// There is no use in repeating
db.operation().deleteOperation(op.id);
if (message != null &&
ex instanceof MessageRemovedException)
// Cleanup
if (message != null)
if (ex instanceof MessageRemovedException) {
db.message().deleteMessage(message.id);
// Delete temporary copy in target folder
if (EntityOperation.MOVE.equals(op.name) && jargs.length() > 1)
db.message().deleteMessage(jargs.getInt(1));
if (EntityOperation.ADD.equals(op.name) && jargs.length() > 0)
db.message().deleteMessage(jargs.getInt(0));
} else
db.message().setMessageUiHide(message.id, false);
continue;
} else if (ex instanceof MessagingException) {
// Socket timeout is a recoverable condition (send message)

Loading…
Cancel
Save