Skip to content

Commit

Permalink
bundle-uri: add trace regions around downloading bundles
Browse files Browse the repository at this point in the history
These values will be used explicitly during tests, but they can also be
informative for users interested in what downloads or copies are
happening.

Signed-off-by: Derrick Stolee <derrickstolee@github.com>
  • Loading branch information
derrickstolee committed Jun 27, 2022
1 parent 4efbcaa commit 15c11bc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bundle-uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ static int download_https_uri_to_file(const char *uri, const char *file)
if (start_command(&cp))
return 1;

trace2_region_enter("bundle-uri", "download_https_uri_to_file", the_repository);

child_in = fdopen(cp.in, "w");
if (!child_in) {
result = 1;
Expand Down Expand Up @@ -313,12 +315,17 @@ static int download_https_uri_to_file(const char *uri, const char *file)
return 1;
if (child_out)
fclose(child_out);
trace2_region_leave("bundle-uri", "download_https_uri_to_file", the_repository);
return result;
}

static int copy_uri_to_file(const char *uri, const char *file)
{
int result;
const char *out;

trace2_data_string("bundle-uri", the_repository, "uri", uri);

if (skip_prefix(uri, "https:", &out) ||
skip_prefix(uri, "http:", &out))
return download_https_uri_to_file(uri, file);
Expand All @@ -327,7 +334,11 @@ static int copy_uri_to_file(const char *uri, const char *file)
out = uri;

/* Copy as a file */
return !!copy_file(file, out, 0);
trace2_region_enter("bundle-uri", "copy_file", the_repository);
result = !!copy_file(file, out, 0);
trace2_region_leave("bundle-uri", "copy_file", the_repository);

return result;
}

static int unbundle_from_file(struct repository *r, const char *file)
Expand Down

0 comments on commit 15c11bc

Please sign in to comment.