mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-12 03:28:09 +00:00
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.
This commit is contained in:
parent
8cec2b8ae9
commit
3c337a5d37
@ -893,6 +893,29 @@ static unsigned long free_unpacked(struct unpacked *n)
|
|||||||
return freed_mem;
|
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,
|
static int find_deltas(git_packbuilder *pb, git_pobject **list,
|
||||||
unsigned int *list_size, unsigned int window,
|
unsigned int *list_size, unsigned int window,
|
||||||
int depth)
|
int depth)
|
||||||
@ -918,6 +941,9 @@ static int find_deltas(git_packbuilder *pb, git_pobject **list,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pb->nr_deltified += 1;
|
||||||
|
report_delta_progress(pb, pb->nr_deltified, false);
|
||||||
|
|
||||||
po = *list++;
|
po = *list++;
|
||||||
(*list_size)--;
|
(*list_size)--;
|
||||||
git_packbuilder__progress_unlock(pb);
|
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;
|
pb->done = true;
|
||||||
git__free(delta_list);
|
git__free(delta_list);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -65,6 +65,7 @@ struct git_packbuilder {
|
|||||||
git_zstream zstream;
|
git_zstream zstream;
|
||||||
|
|
||||||
uint32_t nr_objects,
|
uint32_t nr_objects,
|
||||||
|
nr_deltified,
|
||||||
nr_alloc,
|
nr_alloc,
|
||||||
nr_written,
|
nr_written,
|
||||||
nr_remaining;
|
nr_remaining;
|
||||||
|
Loading…
Reference in New Issue
Block a user