Make sure local folders are always loaded before remote folders.
This might fix an issue where folders are duplicated in FolderTable in the db are duplicated. * src/engine/imap-db/imap-db-account.vala (Account::clone_folder_async): Check the folder hasn't already been loaded before attempting to clone it. * src/engine/imap-engine/imap-engine-generic-account.vala (Account): Only connect/disconnect to Imap.Account's ready signal when opening/closing the account so we don't queue a UpdateRemoteFolders op before loading local folders, but do queue one after a LoadFolders if the remote is already ready. (Account::update_remote_folders): Reset the update timer before queuing the op in case one has been already been recently queued.
This commit is contained in:
parent
d9e23d553e
commit
24b7a95474
2 changed files with 16 additions and 3 deletions
|
|
@ -371,10 +371,15 @@ private class Geary.ImapDB.Account : BaseObject {
|
|||
public async void clone_folder_async(Geary.Imap.Folder imap_folder, Cancellable? cancellable = null)
|
||||
throws Error {
|
||||
check_open();
|
||||
|
||||
|
||||
Geary.Imap.FolderProperties properties = imap_folder.properties;
|
||||
Geary.FolderPath path = imap_folder.path;
|
||||
|
||||
|
||||
// XXX this should really be a db table constraint
|
||||
Geary.ImapDB.Folder? folder = get_local_folder(path);
|
||||
if (folder != null)
|
||||
throw new EngineError.ALREADY_EXISTS(path.to_string());
|
||||
|
||||
yield db.exec_transaction_async(Db.TransactionType.RW, (cx) => {
|
||||
// get the parent of this folder, creating parents if necessary ... ok if this fails,
|
||||
// that just means the folder has no parents
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
|
|||
base (name, information);
|
||||
|
||||
this.remote = remote;
|
||||
this.remote.ready.connect(on_remote_ready);
|
||||
this.remote.report_problem.connect(notify_report_problem);
|
||||
|
||||
this.local = local;
|
||||
|
|
@ -207,12 +206,19 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
|
|||
this.queue_operation(
|
||||
new LoadFolders(this, this.local, get_supported_special_folders())
|
||||
);
|
||||
|
||||
this.remote.ready.connect(on_remote_ready);
|
||||
if (this.remote.is_ready) {
|
||||
this.update_remote_folders();
|
||||
}
|
||||
}
|
||||
|
||||
public override async void close_async(Cancellable? cancellable = null) throws Error {
|
||||
if (!open)
|
||||
return;
|
||||
|
||||
this.remote.ready.disconnect(on_remote_ready);
|
||||
|
||||
// Halt internal tasks early so they stop using local and
|
||||
// remote connections.
|
||||
this.processor.stop();
|
||||
|
|
@ -627,6 +633,8 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
|
|||
* Hooks up and queues an {@link UpdateRemoteFolders} operation.
|
||||
*/
|
||||
private void update_remote_folders() {
|
||||
this.refresh_folder_timer.reset();
|
||||
|
||||
UpdateRemoteFolders op = new UpdateRemoteFolders(
|
||||
this,
|
||||
this.remote,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue