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 Aug 4, 2022
1 parent 9235aa4 commit c76c968
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions bundle-uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ static int download_https_uri_to_file(const char *file, const char *uri)
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 @@ -317,22 +319,29 @@ static int download_https_uri_to_file(const char *file, const char *uri)
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 *filename, const char *uri)
{
int res;
const char *out;

if (starts_with(uri, "https:") ||
starts_with(uri, "http:"))
trace2_data_string("bundle-uri", the_repository, "uri", uri);

if (starts_with(uri, "https://") ||
starts_with(uri, "http://"))
return download_https_uri_to_file(filename, uri);

if (skip_prefix(uri, "file://", &out))
uri = out;

/* Copy as a file */
return copy_file(filename, uri, 0);
trace2_region_enter("bundle-uri", "copy_file", the_repository);
res = copy_file(filename, uri, 0);
trace2_region_leave("bundle-uri", "copy_file", the_repository);
return res;
}

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

0 comments on commit c76c968

Please sign in to comment.