[geary/cherry-pick-11754cb6] Merge branch 'mjog/phantom-parent-folders' into 'mainline'



commit 38ebc64e1b6e2f96800ab75208a6ba2d60e330e1
Author: Michael Gratton <mike vee net>
Date:   Thu Apr 23 01:59:36 2020 +0000

    Merge branch 'mjog/phantom-parent-folders' into 'mainline'
    
    Geary.ImapEngine.GenericAccount: Fix duplicate folders on first load
    
    See merge request GNOME/geary!500
    
    (cherry picked from commit 11754cb63b7e900527465d77a150121ef97051f3)
    
    df2bce4e Geary.ImapEngine.GenericAccount: Fix duplicate folders on first load

 .../imap-engine/imap-engine-generic-account.vala      | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 0605c5de..012dd065 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -1116,11 +1116,20 @@ internal class Geary.ImapEngine.UpdateRemoteFolders : AccountOperation {
     }
 
     public override async void execute(Cancellable cancellable) throws Error {
-        Gee.Map<FolderPath, Geary.Folder> existing_folders =
-            Geary.traverse<Geary.Folder>(this.account.list_folders())
-            .to_hash_map<FolderPath>(f => f.path);
-        Gee.Map<FolderPath, Imap.Folder> remote_folders =
-            new Gee.HashMap<FolderPath, Imap.Folder>();
+        // Use sorted maps here to a) aid debugging, and b) ensure
+        // that parent folders are processed before child folders
+        var existing_folders = new Gee.TreeMap<FolderPath,Folder>(
+            (a,b) => a.compare_to(b)
+        );
+        var remote_folders = new Gee.TreeMap<FolderPath,Imap.Folder>(
+            (a,b) => a.compare_to(b)
+        );
+
+        Geary.traverse<Geary.Folder>(
+            this.account.list_folders()
+        ).add_all_to_map<FolderPath>(
+            existing_folders, f => f.path
+        );
 
         GenericAccount account = (GenericAccount) this.account;
         Imap.AccountSession remote = yield account.claim_account_session(


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]