[geary] Remove Status.RAILED ReplayOperation result code
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Remove Status.RAILED ReplayOperation result code
- Date: Fri, 24 Oct 2014 19:42:44 +0000 (UTC)
commit 643c1d465189eb211288f68ac190aec6f651200f
Author: Jim Nelson <jim yorba org>
Date: Fri Oct 24 12:41:16 2014 -0700
Remove Status.RAILED ReplayOperation result code
Status.FAILED was only being used by CreateEmailOperation, and even
then it was being used inappropriately. ReplayOperations should throw
an Error on failure.
.../imap-engine/imap-engine-minimal-folder.vala | 3 +-
.../imap-engine/imap-engine-replay-operation.vala | 21 ++++-----
.../imap-engine/imap-engine-replay-queue.vala | 43 ++++++++------------
.../replay-ops/imap-engine-create-email.vala | 3 -
4 files changed, 27 insertions(+), 43 deletions(-)
---
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index c8b1aa6..af8750f 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -1303,8 +1303,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.AbstractFolder, Geary.Folde
replay_queue.schedule(op);
- if (!yield op.wait_for_ready_async(cancellable))
- return null;
+ yield op.wait_for_ready_async(cancellable);
// find earliest ID; because all Email comes from Folder, UID should always be present
ImapDB.EmailIdentifier? earliest_id = null;
diff --git a/src/engine/imap-engine/imap-engine-replay-operation.vala
b/src/engine/imap-engine/imap-engine-replay-operation.vala
index 7b1ad33..0dd62e2 100644
--- a/src/engine/imap-engine/imap-engine-replay-operation.vala
+++ b/src/engine/imap-engine/imap-engine-replay-operation.vala
@@ -26,7 +26,6 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
public enum Status {
COMPLETED,
- FAILED,
CONTINUE
}
@@ -36,7 +35,6 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
public int opnum { get; private set; }
public Scope scope { get; private set; }
public Error? err { get; private set; default = null; }
- public bool failed { get; private set; default = false; }
public bool notified { get; private set; default = false; }
private Nonblocking.Semaphore semaphore = new Nonblocking.Semaphore();
@@ -97,10 +95,11 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
*
* Returns:
* COMPLETED: the operation has completed and no further calls should be made.
- * FAILED: the operation has failed. (An exception may be thrown for similar effect.)
- * backout_local_async() will *not* be executed.
* CONTINUE: The local operation has completed and the remote portion must be executed as
* well. This is treated as COMPLETED if get_scope() returns LOCAL_ONLY.
+ *
+ * If Error thrown:
+ * backout_local_async() will *not* be executed.
*/
public abstract async Status replay_local_async() throws Error;
@@ -109,9 +108,10 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
*
* Returns:
* COMPLETED: the operation has completed and no further calls should be made.
- * FAILED: the operation has failed. (An exception may be thrown for similar effect.)
- * backout_local_async() will be executed only if scope is LOCAL_AND_REMOTE.
* CONTINUE: Treated as COMPLETED.
+ *
+ * If Error thrown:
+ * backout_local_async() will be executed only if scope is LOCAL_AND_REMOTE.
*/
public abstract async Status replay_remote_async() throws Error;
@@ -123,23 +123,20 @@ private abstract class Geary.ImapEngine.ReplayOperation : Geary.BaseObject {
/**
* Completes when the operation has completed execution. If the operation threw an error
- * during execution, it will be thrown here. If the operation failed, this returns false.
+ * during execution, it will be thrown here.
*/
- public async bool wait_for_ready_async(Cancellable? cancellable = null) throws Error {
+ public async void wait_for_ready_async(Cancellable? cancellable = null) throws Error {
yield semaphore.wait_async(cancellable);
if (err != null)
throw err;
-
- return failed;
}
- internal void notify_ready(bool failed, Error? err) {
+ internal void notify_ready(Error? err) {
assert(!notified);
notified = true;
- this.failed = failed;
this.err = err;
try {
diff --git a/src/engine/imap-engine/imap-engine-replay-queue.vala
b/src/engine/imap-engine/imap-engine-replay-queue.vala
index b01f1d8..e376774 100644
--- a/src/engine/imap-engine/imap-engine-replay-queue.vala
+++ b/src/engine/imap-engine/imap-engine-replay-queue.vala
@@ -84,14 +84,14 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
op.to_string());
}
- public virtual signal void backing_out(ReplayOperation op, bool failed, Error? err) {
- Logging.debug(Logging.Flag.REPLAY, "[%s] ReplayQueue::backout-out: %s failed=%s err=%s",
- to_string(), op.to_string(), failed.to_string(), (err != null) ? err.message : "(null)");
+ public virtual signal void backing_out(ReplayOperation op, Error? err) {
+ Logging.debug(Logging.Flag.REPLAY, "[%s] ReplayQueue::backout-out: %s err=%s",
+ to_string(), op.to_string(), (err != null) ? err.message : "(null)");
}
- public virtual signal void backed_out(ReplayOperation op, bool failed, Error? err) {
- Logging.debug(Logging.Flag.REPLAY, "[%s] ReplayQueue::backed-out: %s failed=%s err=%s",
- to_string(), op.to_string(), failed.to_string(), (err != null) ? err.message : "(null)");
+ public virtual signal void backed_out(ReplayOperation op, Error? err) {
+ Logging.debug(Logging.Flag.REPLAY, "[%s] ReplayQueue::backed-out: %s err=%s",
+ to_string(), op.to_string(), (err != null) ? err.message : "(null)");
}
public virtual signal void backout_failed(ReplayOperation op, Error? backout_err) {
@@ -393,20 +393,14 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
case ReplayOperation.Status.COMPLETED:
// done
remote_enqueue = false;
- op.notify_ready(false, null);
+ op.notify_ready(null);
break;
case ReplayOperation.Status.CONTINUE:
// don't touch remote_enqueue; if already false, CONTINUE is treated as
// COMPLETED.
if (!remote_enqueue)
- op.notify_ready(false, null);
- break;
-
- case ReplayOperation.Status.FAILED:
- // done
- remote_enqueue = false;
- op.notify_ready(true, null);
+ op.notify_ready(null);
break;
default:
@@ -416,7 +410,7 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
debug("Replay local error for %s on %s: %s", op.to_string(), to_string(),
replay_err.message);
- op.notify_ready(false, replay_err);
+ op.notify_ready(replay_err);
remote_enqueue = false;
}
}
@@ -436,7 +430,7 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
locally_executed(op, remote_enqueue);
if (!remote_enqueue) {
- if (!op.failed && op.err == null)
+ if (op.err == null)
completed(op);
else
failed(op);
@@ -487,11 +481,10 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
remotely_executing(op);
- ReplayOperation.Status status = ReplayOperation.Status.FAILED;
Error? remote_err = null;
if (folder_opened || is_close_op) {
try {
- status = yield op.replay_remote_async();
+ yield op.replay_remote_async();
} catch (Error replay_err) {
debug("Replay remote error for %s on %s: %s", op.to_string(), to_string(),
replay_err.message);
@@ -502,16 +495,14 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
remote_err = new EngineError.SERVER_UNAVAILABLE("Folder %s not available",
owner.to_string());
}
- bool has_failed = !is_close_op && (status == ReplayOperation.Status.FAILED);
-
- // COMPLETED == CONTINUE, only FAILED or exception of interest here
- if (remote_err != null || has_failed) {
+ // COMPLETED == CONTINUE, only exception of interest here if not closing
+ if (remote_err != null && !is_close_op) {
try {
- backing_out(op, has_failed, remote_err);
+ backing_out(op, remote_err);
yield op.backout_local_async();
- backed_out(op, has_failed, remote_err);
+ backed_out(op, remote_err);
} catch (Error backout_err) {
backout_failed(op, backout_err);
}
@@ -519,11 +510,11 @@ private class Geary.ImapEngine.ReplayQueue : Geary.BaseObject {
// use the remote error (not the backout error) for the operation's completion
// state
- op.notify_ready(has_failed, remote_err);
+ op.notify_ready(remote_err);
remotely_executed(op);
- if (!op.failed && op.err == null)
+ if (op.err == null)
completed(op);
else
failed(op);
diff --git a/src/engine/imap-engine/replay-ops/imap-engine-create-email.vala
b/src/engine/imap-engine/replay-ops/imap-engine-create-email.vala
index b27170b..3104c4c 100644
--- a/src/engine/imap-engine/replay-ops/imap-engine-create-email.vala
+++ b/src/engine/imap-engine/replay-ops/imap-engine-create-email.vala
@@ -50,9 +50,6 @@ private class Geary.ImapEngine.CreateEmail : Geary.ImapEngine.SendReplayOperatio
// use IMAP APPEND command on remote folders, which doesn't require opening a folder
created_id = yield engine.remote_folder.create_email_async(rfc822, flags, date_received);
- if (created_id == null)
- return ReplayOperation.Status.FAILED;
-
// If the user cancelled the operation, we need to wipe the new message to keep this
// operation atomic.
if (cancellable.is_cancelled()) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]