Commit 3c337a5d by Carlos Martín Nieto

packbuilder: report progress during deltification

This is useful to send to the client while we're performing the work.

The reporting function has a force parameter which makes sure that we
do send out the message of 100% completed, even if this comes before the
next udpate window.
parent 8cec2b8a
......@@ -893,6 +893,29 @@ static unsigned long free_unpacked(struct unpacked *n)
return freed_mem;
}
static int report_delta_progress(git_packbuilder *pb, uint32_t count, bool force)
{
int ret;
if (pb->progress_cb) {
double current_time = git__timer();
double elapsed = current_time - pb->last_progress_report_time;
if (force || elapsed >= MIN_PROGRESS_UPDATE_INTERVAL) {
pb->last_progress_report_time = current_time;
ret = pb->progress_cb(
GIT_PACKBUILDER_DELTAFICATION,
count, pb->nr_objects, pb->progress_cb_payload);
if (ret)
return giterr_set_after_callback(ret);
}
}
return 0;
}
static int find_deltas(git_packbuilder *pb, git_pobject **list,
unsigned int *list_size, unsigned int window,
int depth)
......@@ -918,6 +941,9 @@ static int find_deltas(git_packbuilder *pb, git_pobject **list,
break;
}
pb->nr_deltified += 1;
report_delta_progress(pb, pb->nr_deltified, false);
po = *list++;
(*list_size)--;
git_packbuilder__progress_unlock(pb);
......@@ -1290,6 +1316,8 @@ static int prepare_pack(git_packbuilder *pb)
}
}
report_delta_progress(pb, pb->nr_objects, true);
pb->done = true;
git__free(delta_list);
return 0;
......
......@@ -65,6 +65,7 @@ struct git_packbuilder {
git_zstream zstream;
uint32_t nr_objects,
nr_deltified,
nr_alloc,
nr_written,
nr_remaining;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment