From 276e3a5e7b5c5396b66e1d99dfaf98fd3a948ce9 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Mon, 11 Nov 2019 14:56:02 -0500 Subject: [PATCH] gvfs-helper: handle pack-file after single POST request If our POST request includes a commit ID, then the the remote will send a pack-file containing the commit and all trees reachable from its root tree. With the current implementation, this causes a failure since we call install_loose() when asking for one object. Modify the condition to check for install_pack() when the response type changes. Also, create a tempfile for the pack-file download or else we will have problems! Signed-off-by: Derrick Stolee --- gvfs-helper.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gvfs-helper.c b/gvfs-helper.c index 1b8847f08f0642..2f2f26f72810d5 100644 --- a/gvfs-helper.c +++ b/gvfs-helper.c @@ -1126,7 +1126,9 @@ static void gh__run_one_slot(struct active_request_slot *slot, stop_progress(¶ms->progress); if (status->ec == GH__ERROR_CODE__OK && params->b_write_to_file) { - if (params->b_is_post && params->object_count > 1) + if (params->b_is_post && + !strcmp(status->content_type.buf, + "application/x-git-packfile")) install_packfile(params, status); else install_loose(params, status); @@ -2285,10 +2287,10 @@ static void do_req(const char *url_base, if (params->tempfile) delete_tempfile(¶ms->tempfile); - if (params->b_is_post && params->object_count > 1) + if (params->b_is_post) create_tempfile_for_packfile(params, status); - else - create_tempfile_for_loose(params, status); + + create_tempfile_for_loose(params, status); if (!params->tempfile || status->ec != GH__ERROR_CODE__OK) return;