[geary/wip/713150-conversations] Fix edge conditions in AccountSynchonizer



commit ff1e195d496dc8d2b0a0b024a1dbf4c78a9cebdf
Author: Jim Nelson <jim yorba org>
Date:   Fri Mar 20 20:46:05 2015 -0700

    Fix edge conditions in AccountSynchonizer

 .../imap-engine-account-synchronizer.vala          |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-account-synchronizer.vala 
b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
index 57dadc4..3b30d02 100644
--- a/src/engine/imap-engine/imap-engine-account-synchronizer.vala
+++ b/src/engine/imap-engine/imap-engine-account-synchronizer.vala
@@ -332,6 +332,10 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
             debug("Unable to fetch oldest local email for %s: %s", folder.to_string(), err.message);
         }
         
+        ImapDB.EmailIdentifier? imapdb_id = oldest_local_id as ImapDB.EmailIdentifier;
+        if (imapdb_id != null && imapdb_id.uid.value == Imap.UID.MIN)
+            return true;
+        
         if (availability_check) {
             // Compare the oldest mail in the local store and see if it is before the epoch; if so, no
             // need to synchronize simply because this Folder is available; wait for its contents to
@@ -340,10 +344,10 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
                 if (oldest_local.compare(epoch) < 0) {
                     // Oldest local email before epoch, don't sync from network
                     return true;
-                } else if (folder.properties.email_total == local_count) {
+                } else if (folder.properties.email_total <= local_count) {
                     // Local earliest email is after epoch, but there's nothing before it
                     return true;
-                } else {
+                } else if (!epoch.equal(max_epoch)) {
                     debug("Oldest local email in %s not old enough (%s vs. %s), email_total=%d vs. 
local_count=%d, synchronizing...",
                         folder.to_string(), oldest_local.to_string(), epoch.to_string(),
                         folder.properties.email_total, local_count);
@@ -459,6 +463,10 @@ private class Geary.ImapEngine.AccountSynchronizer : Geary.BaseObject {
                         // use earliest email from that span for the next round
                         oldest_local_id = earliest_span_id;
                     }
+                    
+                    ImapDB.EmailIdentifier? imapdb_id = oldest_local_id as ImapDB.EmailIdentifier;
+                    if (imapdb_id != null && imapdb_id.uid.value <= Imap.UID.MIN)
+                        break;
                 }
                 
                 yield Scheduler.sleep_ms_async(200);


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