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 Jul 25, 2022
1 parent 2e02974 commit bb624fd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions bundle-uri.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,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 @@ -312,6 +314,7 @@ 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;
}

Expand All @@ -320,6 +323,8 @@ static int copy_uri_to_file(const char *filename, int fd, const char *uri)
int res, uri_fd;
const char *out;

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

if (skip_prefix(uri, "https:", &out) ||
skip_prefix(uri, "http:", &out)) {
close(fd);
Expand All @@ -331,13 +336,15 @@ static int copy_uri_to_file(const char *filename, int fd, const char *uri)
out = uri;

/* Copy as a file */
trace2_region_enter("bundle-uri", "copy_file", the_repository);
uri_fd = open(out, 0);

if (uri_fd < 0)
return -1;

res = copy_fd(uri_fd, fd);
close(uri_fd);
trace2_region_leave("bundle-uri", "copy_file", the_repository);
return res;
}

Expand Down

0 comments on commit bb624fd

Please sign in to comment.