Handle folder operation errors

pull/195/head
M66B 4 years ago
parent 3d081bf8f4
commit 5c499d351c

@ -1756,52 +1756,61 @@ class Core {
List<EntityFolder> folders = db.folder().getFolders(account.id, false, false); List<EntityFolder> folders = db.folder().getFolders(account.id, false, false);
for (EntityFolder folder : folders) for (EntityFolder folder : folders)
if (folder.tbc != null) { if (folder.tbc != null) {
Log.i(folder.name + " creating"); try {
Folder ifolder = istore.getFolder(folder.name); Log.i(folder.name + " creating");
if (!ifolder.exists()) { Folder ifolder = istore.getFolder(folder.name);
ifolder.create(Folder.HOLDS_MESSAGES); if (!ifolder.exists()) {
ifolder.setSubscribed(true); ifolder.create(Folder.HOLDS_MESSAGES);
ifolder.setSubscribed(true);
}
local.put(folder.name, folder);
} finally {
db.folder().resetFolderTbc(folder.id);
sync_folders = true;
} }
db.folder().resetFolderTbc(folder.id);
local.put(folder.name, folder);
sync_folders = true;
} else if (folder.rename != null) { } else if (folder.rename != null) {
Log.i(folder.name + " rename into " + folder.rename); try {
Folder ifolder = istore.getFolder(folder.name); Log.i(folder.name + " rename into " + folder.rename);
if (ifolder.exists()) { Folder ifolder = istore.getFolder(folder.name);
// https://tools.ietf.org/html/rfc3501#section-6.3.9 if (ifolder.exists()) {
boolean subscribed = ifolder.isSubscribed(); // https://tools.ietf.org/html/rfc3501#section-6.3.9
if (subscribed) boolean subscribed = ifolder.isSubscribed();
ifolder.setSubscribed(false); if (subscribed)
ifolder.setSubscribed(false);
Folder itarget = istore.getFolder(folder.rename);
ifolder.renameTo(itarget); Folder itarget = istore.getFolder(folder.rename);
ifolder.renameTo(itarget);
if (subscribed && folder.selectable)
try { if (subscribed && folder.selectable)
itarget.open(READ_WRITE); try {
itarget.setSubscribed(subscribed); itarget.open(READ_WRITE);
itarget.close(); itarget.setSubscribed(subscribed);
} catch (MessagingException ex) { itarget.close();
Log.w(ex); } catch (MessagingException ex) {
} Log.w(ex);
}
db.folder().renameFolder(folder.account, folder.name, folder.rename); db.folder().renameFolder(folder.account, folder.name, folder.rename);
folder.name = folder.rename; folder.name = folder.rename;
}
} finally {
db.folder().resetFolderRename(folder.id);
sync_folders = true;
} }
db.folder().resetFolderRename(folder.id);
sync_folders = true;
} else if (folder.tbd != null && folder.tbd) { } else if (folder.tbd != null && folder.tbd) {
Log.i(folder.name + " deleting"); try {
Folder ifolder = istore.getFolder(folder.name); Log.i(folder.name + " deleting");
if (ifolder.exists()) { Folder ifolder = istore.getFolder(folder.name);
ifolder.setSubscribed(false); if (ifolder.exists()) {
ifolder.delete(false); ifolder.setSubscribed(false);
ifolder.delete(false);
}
} finally {
db.folder().deleteFolder(folder.id);
sync_folders = true;
} }
db.folder().deleteFolder(folder.id);
sync_folders = true;
} else { } else {
if (EntityFolder.DRAFTS.equals(folder.type)) if (EntityFolder.DRAFTS.equals(folder.type))

Loading…
Cancel
Save