Simplify the process of creating new local folders somewhat
Enable local folders to be created with one call, rather than two.
This commit is contained in:
parent
3e461e7b45
commit
b4749cce39
2 changed files with 17 additions and 21 deletions
|
|
@ -384,9 +384,10 @@ private class Geary.ImapDB.Account : BaseObject {
|
|||
private void on_outbox_email_sent(Geary.RFC822.Message rfc822) {
|
||||
email_sent(rfc822);
|
||||
}
|
||||
|
||||
public async void clone_folder_async(Geary.Imap.Folder imap_folder, Cancellable? cancellable = null)
|
||||
throws Error {
|
||||
|
||||
public async Folder clone_folder_async(Geary.Imap.Folder imap_folder,
|
||||
GLib.Cancellable? cancellable = null)
|
||||
throws GLib.Error {
|
||||
check_open();
|
||||
|
||||
Geary.Imap.FolderProperties properties = imap_folder.properties;
|
||||
|
|
@ -426,8 +427,11 @@ private class Geary.ImapDB.Account : BaseObject {
|
|||
|
||||
return Db.TransactionOutcome.COMMIT;
|
||||
}, cancellable);
|
||||
|
||||
// XXX can't we create this from the INSERT above?
|
||||
return yield fetch_folder_async(path, cancellable);
|
||||
}
|
||||
|
||||
|
||||
public async void delete_folder_async(Geary.Folder folder, Cancellable? cancellable)
|
||||
throws Error {
|
||||
check_open();
|
||||
|
|
|
|||
|
|
@ -1240,27 +1240,19 @@ internal class Geary.ImapEngine.UpdateRemoteFolders : AccountOperation {
|
|||
.map<Geary.Folder>(e => (Geary.Folder) e.value)
|
||||
.to_array_list();
|
||||
|
||||
// For folders to add, clone them and their properties locally
|
||||
// For folders to add, clone them and their properties
|
||||
// locally, then add to the account
|
||||
ImapDB.Account local = ((GenericAccount) this.account).local;
|
||||
foreach (Geary.Imap.Folder remote_folder in to_add) {
|
||||
try {
|
||||
yield local.clone_folder_async(remote_folder, cancellable);
|
||||
} catch (Error err) {
|
||||
debug("Unable to add/remove folder %s to local store: %s", remote_folder.path.to_string(),
|
||||
err.message);
|
||||
}
|
||||
}
|
||||
|
||||
// Create Geary.Folder objects for all added folders
|
||||
Gee.ArrayList<ImapDB.Folder> to_build = new Gee.ArrayList<ImapDB.Folder>();
|
||||
foreach (Geary.Imap.Folder remote_folder in to_add) {
|
||||
try {
|
||||
to_build.add(yield local.fetch_folder_async(remote_folder.path, cancellable));
|
||||
} catch (Error convert_err) {
|
||||
// This isn't fatal, but irksome ... in the future, when local folders are
|
||||
// removed, it's possible for one to disappear between cloning it and fetching
|
||||
// it
|
||||
debug("Unable to fetch local folder after cloning: %s", convert_err.message);
|
||||
to_build.add(
|
||||
yield local.clone_folder_async(remote_folder, cancellable)
|
||||
);
|
||||
} catch (Error err) {
|
||||
debug("Unable to clone folder %s in local store: %s",
|
||||
remote_folder.path.to_string(),
|
||||
err.message);
|
||||
}
|
||||
}
|
||||
this.generic_account.add_folders(to_build, false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue