1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-27 18:27:43 +00:00

Improved folder deletion

This commit is contained in:
M66B 2023-02-17 09:18:38 +01:00
parent cf131f0682
commit fe783a0799

View file

@ -2295,7 +2295,9 @@ class Core {
EntityLog.log(context, folder.name + " creating");
Folder ifolder = istore.getFolder(folder.name);
if (!ifolder.exists())
if (ifolder.exists())
EntityLog.log(context, folder.name + " already exists on server");
else
try {
((IMAPFolder) ifolder).doCommand(new IMAPFolder.ProtocolCommand() {
@Override
@ -2357,16 +2359,29 @@ class Core {
EntityLog.log(context, folder.name + " deleting server");
Folder ifolder = istore.getFolder(folder.name);
if (ifolder.exists()) {
ifolder.setSubscribed(false);
ifolder.delete(false);
}
EntityLog.log(context, folder.name + " deleting device");
db.folder().deleteFolder(folder.id);
try {
ifolder.setSubscribed(false);
((IMAPFolder) ifolder).doCommand(new IMAPFolder.ProtocolCommand() {
@Override
public Object doCommand(IMAPProtocol protocol) throws ProtocolException {
protocol.delete(folder.name);
return null;
}
});
EntityLog.log(context, folder.name + " deleting device");
db.folder().deleteFolder(folder.id);
} catch (MessagingException ex) {
Log.w(ex);
EntityLog.log(context, folder.name + " deletion " +
ex + "\n" + android.util.Log.getStackTraceString(ex));
db.account().setAccountError(account.id, Log.formatThrowable(ex));
}
} else
EntityLog.log(context, folder.name + " does not exist on server anymore");
} finally {
db.folder().resetFolderTbd(folder.id);
sync_folders = true;
}
EntityLog.log(context, folder.name + " deleted");
} else {
if (EntityFolder.DRAFTS.equals(folder.type))