aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2025-06-18 15:33:33 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2025-06-18 16:10:33 -0400
commit9d3d3de1ae62d103cadf56d437d0e4d66e8740b3 (patch)
treee31fa3ed199ecd99f8690701c2d11dca8c624297
parent1fe4dec61c0599335bf1357fda527722a90fb491 (diff)
downloadstasis-9d3d3de1ae62d103cadf56d437d0e4d66e8740b3.tar.gz
Handle download() errors
-rw-r--r--src/lib/core/conda.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/lib/core/conda.c b/src/lib/core/conda.c
index 2b73862..268b433 100644
--- a/src/lib/core/conda.c
+++ b/src/lib/core/conda.c
@@ -24,7 +24,12 @@ int micromamba(const struct MicromambaInfo *info, char *command, ...) {
sprintf(installer_path, "%s/latest", getenv("TMPDIR") ? getenv("TMPDIR") : "/tmp");
if (access(installer_path, F_OK)) {
- download(url, installer_path, NULL);
+ char *errmsg = NULL;
+ const long http_code = download(url, installer_path, &errmsg);
+ if (HTTP_ERROR(http_code)) {
+ fprintf(stderr, "download failed: %ld: %s\n", http_code, errmsg);
+ return -1;
+ }
}
char mmbin[PATH_MAX];
@@ -552,7 +557,15 @@ int conda_env_create_from_uri(char *name, char *uri, char *python_version) {
// We'll create a new file with the same random bits, ending with .yml
strcat(tempfile, ".yml");
char *errmsg = NULL;
- download(uri_fs ? uri_fs : uri, tempfile, &errmsg);
+ const long http_code = download(uri_fs ? uri_fs : uri, tempfile, &errmsg);
+ if (HTTP_ERROR(http_code)) {
+ if (errmsg) {
+ fprintf(stderr, "download failed: %ld: %s\n", http_code, errmsg);
+ guard_free(errmsg);
+ }
+ guard_free(uri_fs);
+ return -1;
+ }
guard_free(uri_fs);
// Rewrite python version