diff options
| author | forever2k38 <forever2k38@noreply.codeberg.org> | 2026-09-07 12:59:05 +0200 |
|---|---|---|
| committer | forever2k38 <forever2k38@noreply.codeberg.org> | 2026-09-07 12:59:05 +0200 |
| commit | 6649d2bd7b512f96a42ed9035291f97b4a5ef3c5 (patch) | |
| tree | a4551c9f8cae562da3a12b2ef76d064adc6be396 /src | |
| parent | 1371aac8280c8281d7b79926fc7b8d8e38cda3ab (diff) | |
fix: skip temporary directory creation error if it already exists
Diffstat (limited to 'src')
| -rw-r--r-- | src/download.c | 12 | ||||
| -rw-r--r-- | src/paths.c | 11 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/download.c b/src/download.c index 351a36b..a833932 100644 --- a/src/download.c +++ b/src/download.c @@ -15,9 +15,6 @@ int pow_download_file(char *path, char *url) { FILE *pagefile; CURL *curl = curl_easy_init(); - printf("%s", path); - printf("%s", url); - if (!curl) { printf("failed to init curl\n"); @@ -27,6 +24,7 @@ int pow_download_file(char *path, char *url) { curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_cb); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); + curl_easy_setopt(curl, CURLOPT_USERAGENT, "pow! (codeberg.org/einfach/pow)"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); @@ -57,7 +55,13 @@ int pow_download_source(pow_package_source *src, const char *prefix) { snprintf(full_path, len, "%s/%s", prefix, src->out); - pow_download_file(full_path, src->in); + printf("downloading source file: %s", src->in); + + if (pow_download_file(full_path, src->in)) { + printf("failed to download sources, aborting\n"); + + return 1; + } return 0; } diff --git a/src/paths.c b/src/paths.c index 5c8121a..d4239ff 100644 --- a/src/paths.c +++ b/src/paths.c @@ -1,12 +1,23 @@ #include "paths.h" +#include "errno.h" #include "stdio.h" #include "stdlib.h" #include "string.h" +#include "sys/stat.h" +#include "unistd.h" char template[] = "/tmp/pow/XXXXXX"; int pow_create_dir_for_package(char **path) { + if (mkdir("/tmp/pow", 0700)) { + if (errno != EEXIST) { + printf("failed to create temp dir\n"); + + return 1; + } + } + char *new_path = malloc(strlen(template) + 1); if (!new_path) { |
