Fixed purge race condition

pull/187/head
M66B 4 years ago
parent 3462554fae
commit 5fdf8df87a

@ -1789,8 +1789,6 @@ class Core {
private static void onPurgeFolder(Context context, JSONArray jargs, EntityFolder folder, IMAPFolder ifolder) throws MessagingException { private static void onPurgeFolder(Context context, JSONArray jargs, EntityFolder folder, IMAPFolder ifolder) throws MessagingException {
// Delete all messages from folder // Delete all messages from folder
DB db = DB.getInstance(context);
try { try {
final MessageSet[] sets = new MessageSet[]{new MessageSet(1, ifolder.getMessageCount())}; final MessageSet[] sets = new MessageSet[]{new MessageSet(1, ifolder.getMessageCount())};
@ -1810,15 +1808,12 @@ class Core {
Log.e(ex); Log.e(ex);
throw ex; throw ex;
} finally { } finally {
int count = MessageHelper.getMessageCount(ifolder); EntityOperation.sync(context, folder.id, false);
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
// Delete local, hidden messages
onPurgeFolder(context, folder);
} }
} }
private static void onPurgeFolder(Context context, EntityFolder folder) { private static void onPurgeFolder(Context context, EntityFolder folder) {
// POP3
DB db = DB.getInstance(context); DB db = DB.getInstance(context);
try { try {
db.beginTransaction(); db.beginTransaction();

@ -34,6 +34,7 @@ public interface DaoOperation {
" WHEN operation.name = '" + EntityOperation.ATTACHMENT + "' THEN -3" + " WHEN operation.name = '" + EntityOperation.ATTACHMENT + "' THEN -3" +
" WHEN operation.name = '" + EntityOperation.HEADERS + "' THEN -2" + " WHEN operation.name = '" + EntityOperation.HEADERS + "' THEN -2" +
" WHEN operation.name = '" + EntityOperation.RAW + "' THEN -2" + " WHEN operation.name = '" + EntityOperation.RAW + "' THEN -2" +
" WHEN operation.name = '" + EntityOperation.PURGE + "' THEN -2" +
" WHEN operation.name = '" + EntityOperation.SYNC + "' AND folder.account IS NULL THEN -1" + // Outbox " WHEN operation.name = '" + EntityOperation.SYNC + "' AND folder.account IS NULL THEN -1" + // Outbox
" WHEN operation.name = '" + EntityOperation.SYNC + "' AND folder.account IS NOT NULL THEN 1" + " WHEN operation.name = '" + EntityOperation.SYNC + "' AND folder.account IS NOT NULL THEN 1" +
// Other operations: add, delete, seen, answered, flag, keyword, label, subscribe, send // Other operations: add, delete, seen, answered, flag, keyword, label, subscribe, send

@ -736,7 +736,6 @@ public class FragmentFolders extends FragmentBase {
} }
EntityOperation.queue(context, folder, EntityOperation.PURGE); EntityOperation.queue(context, folder, EntityOperation.PURGE);
EntityOperation.sync(context, folder.id, false);
db.setTransactionSuccessful(); db.setTransactionSuccessful();
} finally { } finally {

@ -7278,7 +7278,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
EntityOperation.queue(context, folder, EntityOperation.PURGE); EntityOperation.queue(context, folder, EntityOperation.PURGE);
EntityOperation.sync(context, folder.id, false);
} }
db.setTransactionSuccessful(); db.setTransactionSuccessful();

Loading…
Cancel
Save