[geary] Misc non-selectable mailbox fixes



commit f76764814c520c21bd652be35922e021d6764e8d
Author: Michael Gratton <mike vee net>
Date:   Sat Dec 29 13:50:05 2018 +1100

    Misc non-selectable mailbox fixes
    
    Force folder closed again when trying to open an is non-selectable.
    Don't attempt to sync mailboxes that aren't selectable, are local only,
    etc.

 .../imap-engine-account-synchronizer.vala          | 51 +++++++++++++---------
 .../imap-engine/imap-engine-minimal-folder.vala    |  9 +++-
 2 files changed, 39 insertions(+), 21 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-account-synchronizer.vala 
b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
index 33ded58f..abe1fafe 100644
--- a/src/engine/imap-engine/imap-engine-account-synchronizer.vala
+++ b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
@@ -30,27 +30,38 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
 
     private void send_all(Gee.Collection<Folder> folders, bool became_available) {
         foreach (Folder folder in folders) {
+            // Only sync folders that:
+            // 1. Can actually be opened (i.e. are selectable)
+            // 2. Are remote backed
+            // and 3. if considering a folder not because it's
+            // contents changed (i.e. didn't just become available,
+            // only sync if closed, otherwise he folder will keep
+            // track of changes as they occur
+            //
+            // All this implies the folder must be a MinimalFolder and
+            // we do require that for syncing at the moment anyway,
+            // but keep the tests in for that one glorious day where
+            // we can just use a generic folder.
+            debug("Is folder \"%s\" openable: %s", folder.path.to_string(), 
folder.properties.is_openable.to_string());
             MinimalFolder? imap_folder = folder as MinimalFolder;
-            // only deal with ImapEngine.MinimalFolder
-            if (imap_folder == null)
-                continue;
-
-            // if considering folder not because it's available (i.e. because its contents changed),
-            // and the folder is open, don't process it; MinimalFolder will take care of changes as
-            // they occur, in order to remain synchronized
-            if (!became_available &&
-                imap_folder.get_open_state() != Folder.OpenState.CLOSED) {
-                continue;
-            }
-
-            AccountOperation op = became_available
-                ? new CheckFolderSync(this.account, imap_folder, this.max_epoch)
-                : new RefreshFolderSync(this.account, imap_folder);
-
-            try {
-                this.account.queue_operation(op);
-            } catch (Error err) {
-                debug("Failed to queue sync operation: %s", err.message);
+            if (imap_folder != null &&
+                folder.properties.is_openable.is_possible() &&
+                !folder.properties.is_local_only &&
+                !folder.properties.is_virtual &&
+                (became_available ||
+                 imap_folder.get_open_state() == Folder.OpenState.CLOSED)) {
+
+                AccountOperation op = became_available
+                    ? new CheckFolderSync(
+                        this.account, imap_folder, this.max_epoch
+                    )
+                    : new RefreshFolderSync(this.account, imap_folder);
+
+                try {
+                    this.account.queue_operation(op);
+                } catch (Error err) {
+                    debug("Failed to queue sync operation: %s", err.message);
+                }
             }
         }
     }
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala 
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index abbca331..5baf1cb4 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -944,12 +944,19 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
             // Fine, just bail out
             return;
         } catch (EngineError.NOT_FOUND err) {
-            // Folder no longer exists, so force closed
+            debug("Remote folder not found, forcing closed");
+            yield force_close(
+                CloseReason.LOCAL_CLOSE, CloseReason.REMOTE_ERROR
+            );
+            return;
+        } catch (ImapError.NOT_SUPPORTED err) {
+            debug("Remote folder not selectable, forcing closed");
             yield force_close(
                 CloseReason.LOCAL_CLOSE, CloseReason.REMOTE_ERROR
             );
             return;
         } catch (Error err) {
+            debug("Other error: %s", err.message);
             // Notify that there was a connection error, but don't
             // force the folder closed, since it might come good again
             // if the user fixes an auth problem or the network comes


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