Fixed purge race condition

This commit is contained in:
M66B 2020-10-22 11:09:10 +02:00
parent 3462554fae
commit 5fdf8df87a
4 changed files with 3 additions and 9 deletions

View File

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

View File

@ -34,6 +34,7 @@ public interface DaoOperation {
" WHEN operation.name = '" + EntityOperation.ATTACHMENT + "' THEN -3" +
" WHEN operation.name = '" + EntityOperation.HEADERS + "' 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 NOT NULL THEN 1" +
// Other operations: add, delete, seen, answered, flag, keyword, label, subscribe, send

View File

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

View File

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