[geary/wip/778276-better-flag-updates: 10/17] Make sure local folders are always loaded before remote folders.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/778276-better-flag-updates: 10/17] Make sure local folders are always loaded before remote folders.
- Date: Tue, 5 Dec 2017 01:57:59 +0000 (UTC)
commit 0829c2a55c644b689db801e356e9d2e37f660e56
Author: Michael James Gratton <mike vee net>
Date: Tue Nov 28 09:51:53 2017 +1100
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.
src/engine/imap-db/imap-db-account.vala | 9 +++++++--
.../imap-engine/imap-engine-generic-account.vala | 10 +++++++++-
2 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/engine/imap-db/imap-db-account.vala b/src/engine/imap-db/imap-db-account.vala
index 6870dfa..33581b4 100644
--- a/src/engine/imap-db/imap-db-account.vala
+++ b/src/engine/imap-db/imap-db-account.vala
@@ -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
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 336b714..ad3e44d 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]