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

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

Loading…
Cancel
Save