[geary/wip/768422-namespace-support] Minor special use handling clean up.



commit 24bed9074fd9d4d1421188147874e23a1f20e200
Author: Michael James Gratton <mike vee net>
Date:   Fri Nov 3 13:56:07 2017 +1100

    Minor special use handling clean up.
    
    * src/engine/imap-engine/imap-engine-generic-account.vala
      (Account::update_folders_async): Don't fall over creating special use
      folders if only one fails.
    
    * src/engine/imap/response/imap-mailbox-attributes.vala
      (MailboxAttributes::get_special_folder_type): Remove duplicate clause.

 .../imap-engine/imap-engine-generic-account.vala   |   20 +++++++++-----------
 .../imap/response/imap-mailbox-attributes.vala     |    9 +++------
 2 files changed, 12 insertions(+), 17 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala 
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 10ddf82..5ed6024 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -737,11 +737,6 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
         return yield ensure_special_folder_async(special, cancellable);
     }
 
-    private async void ensure_special_folders_async(Cancellable? cancellable) throws Error {
-        foreach (Geary.SpecialFolderType special in get_supported_special_folders())
-            yield ensure_special_folder_async(special, cancellable);
-    }
-
     private async void update_folders_async(Gee.Map<FolderPath, Geary.Folder> existing_folders,
         Gee.Map<FolderPath, Imap.Folder> remote_folders, bool remote_folders_suspect, Cancellable? 
cancellable) {
         // update all remote folders properties in the local store and active in the system
@@ -855,14 +850,17 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
             if (altered.size > 0)
                 notify_folders_contents_altered(altered);
         }
-        
-        try {
-            yield ensure_special_folders_async(cancellable);
-        } catch (Error e) {
-            warning("Unable to ensure special folders: %s", e.message);
+
+        // Ensure each of the important special folders we need already exist
+        foreach (Geary.SpecialFolderType special in get_supported_special_folders()) {
+            try {
+                yield ensure_special_folder_async(special, cancellable);
+            } catch (Error e) {
+                warning("Unable to ensure special folder %s: %s", special.to_string(), e.message);
+            }
         }
     }
-    
+
     public override async void send_email_async(Geary.ComposedEmail composed,
         Cancellable? cancellable = null) throws Error {
         check_open();
diff --git a/src/engine/imap/response/imap-mailbox-attributes.vala 
b/src/engine/imap/response/imap-mailbox-attributes.vala
index 18dc562..42abc8f 100644
--- a/src/engine/imap/response/imap-mailbox-attributes.vala
+++ b/src/engine/imap/response/imap-mailbox-attributes.vala
@@ -74,6 +74,9 @@ public class Geary.Imap.MailboxAttributes : Geary.Imap.Flags {
         if (contains(MailboxAttribute.SPECIAL_FOLDER_SENT))
             return Geary.SpecialFolderType.SENT;
         
+        if (contains(MailboxAttribute.SPECIAL_FOLDER_JUNK))
+            return Geary.SpecialFolderType.SPAM;
+        
         if (contains(MailboxAttribute.SPECIAL_FOLDER_SPAM))
             return Geary.SpecialFolderType.SPAM;
         
@@ -83,18 +86,12 @@ public class Geary.Imap.MailboxAttributes : Geary.Imap.Flags {
         if (contains(MailboxAttribute.SPECIAL_FOLDER_IMPORTANT))
             return Geary.SpecialFolderType.IMPORTANT;
         
-        if (contains(MailboxAttribute.SPECIAL_FOLDER_ALL))
-            return Geary.SpecialFolderType.ALL_MAIL;
-        
         if (contains(MailboxAttribute.SPECIAL_FOLDER_ARCHIVE))
             return Geary.SpecialFolderType.ARCHIVE;
         
         if (contains(MailboxAttribute.SPECIAL_FOLDER_FLAGGED))
             return Geary.SpecialFolderType.FLAGGED;
         
-        if (contains(MailboxAttribute.SPECIAL_FOLDER_JUNK))
-            return Geary.SpecialFolderType.SPAM;
-        
         return Geary.SpecialFolderType.NONE;
     }
 }


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