Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJameson Miller <jamill@microsoft.com>2013-12-02 23:09:12 +0400
committerJameson Miller <jamill@microsoft.com>2013-12-03 08:05:10 +0400
commitdb4cbfe5041d2dca342b123c14259d1860ed4c8c (patch)
treec64ba57b75a99a7cf0a7877fcf70ca02f83bfdff /src/transports/smart_protocol.c
parent14984af6cb9906746d2c64c5df7542ecd7406b16 (diff)
Updates to cancellation logic during download and indexing of packfile.
Diffstat (limited to 'src/transports/smart_protocol.c')
-rw-r--r--src/transports/smart_protocol.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/transports/smart_protocol.c b/src/transports/smart_protocol.c
index 3bf1f9329..a4046ee43 100644
--- a/src/transports/smart_protocol.c
+++ b/src/transports/smart_protocol.c
@@ -521,7 +521,7 @@ int git_smart__download_pack(
/* Check cancellation before network call */
if (t->cancelled.val) {
- giterr_set(GITERR_NET, "The fetch was cancelled by the user");
+ giterr_clear();
error = GIT_EUSER;
goto done;
}
@@ -531,7 +531,7 @@ int git_smart__download_pack(
/* Check cancellation after network call */
if (t->cancelled.val) {
- giterr_set(GITERR_NET, "The fetch was cancelled by the user");
+ giterr_clear();
error = GIT_EUSER;
goto done;
}
@@ -540,8 +540,9 @@ int git_smart__download_pack(
if (t->progress_cb) {
git_pkt_progress *p = (git_pkt_progress *) pkt;
if (t->progress_cb(p->data, p->len, t->message_cb_payload)) {
- giterr_set(GITERR_NET, "The fetch was cancelled by the user");
- return GIT_EUSER;
+ giterr_clear();
+ error = GIT_EUSER;
+ goto done;
}
}
git__free(pkt);
@@ -559,16 +560,29 @@ int git_smart__download_pack(
}
} while (1);
+ /*
+ * Trailing execution of progress_cb, if necessary...
+ * Only the callback through the npp datastructure currently
+ * updates the last_fired_bytes value. It is possible that
+ * progress has already been reported with the correct
+ * "received_bytes" value, but until (if?) this is unified
+ * then we will report progress again to be sure that the
+ * correct last received_bytes value is reported.
+ */
+ if (npp.callback && npp.stats->received_bytes > npp.last_fired_bytes) {
+ if (npp.callback(npp.stats, npp.payload) < 0) {
+ giterr_clear();
+ error = GIT_EUSER;
+ goto done;
+ }
+ }
+
error = writepack->commit(writepack, stats);
done:
if (writepack)
writepack->free(writepack);
- /* Trailing execution of progress_cb, if necessary */
- if (npp.callback && npp.stats->received_bytes > npp.last_fired_bytes)
- npp.callback(npp.stats, npp.payload);
-
return error;
}