[geary/wip/713530-background-sync: 3/9] Ensure EmailStore always closes folders when executing an operation.
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/713530-background-sync: 3/9] Ensure EmailStore always closes folders when executing an operation.
- Date: Fri, 1 Dec 2017 02:30:03 +0000 (UTC)
commit f8dc87cb36616725cfcdb6524025c736d67cdc66
Author: Michael James Gratton <mike vee net>
Date: Tue Nov 28 17:40:15 2017 +1100
Ensure EmailStore always closes folders when executing an operation.
src/engine/app/app-email-store.vala | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
---
diff --git a/src/engine/app/app-email-store.vala b/src/engine/app/app-email-store.vala
index 312c829..4390dfa 100644
--- a/src/engine/app/app-email-store.vala
+++ b/src/engine/app/app-email-store.vala
@@ -181,30 +181,31 @@ public class Geary.App.EmailStore : BaseObject {
try {
debug("EmailStore opening %s for %s on %d emails", folder.to_string(),
operation.get_type().name(), ids.size);
-
+
yield folder.open_async(Geary.Folder.OpenFlags.FAST_OPEN, cancellable);
open = true;
-
used_ids = yield operation.execute_async(folder, ids, cancellable);
-
- yield folder.close_async(cancellable);
- open = false;
-
- debug("EmailStore closed %s after %s on %d emails", folder.to_string(),
- operation.get_type().name(), ids.size);
} catch (Error e) {
debug("Error performing an operation on messages in %s: %s", folder.to_string(), e.message);
-
+ } finally {
if (open) {
try {
- yield folder.close_async(cancellable);
- open = false;
+ // Don't use the cancellable here, if it's been
+ // opened we need to try to close it.
+ yield folder.close_async(null);
+ debug(
+ "EmailStore closed %s after %s on %d emails",
+ folder.to_string(),
+ operation.get_type().name(),
+ ids.size
+ );
} catch (Error e) {
- debug("Error closing folder %s: %s", folder.to_string(), e.message);
+ debug("Error closing folder %s: %s",
+ folder.to_string(), e.message);
}
}
}
-
+
// We don't want to operate on any mails twice.
if (used_ids != null) {
foreach (Geary.EmailIdentifier id in used_ids.to_array()) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]