From 3612510ee0b4d67a05f7bbdbfa9bf90d4f0e72bd Mon Sep 17 00:00:00 2001 From: morganamilo Date: Tue, 20 May 2025 13:45:02 +0100 Subject: [PATCH] libalpm: add new errno for download initialization The error string "failed to retrieve some files" implies that the download may have begun and some files may have been partially downloaded. If we know no download actually took place we can be more clear about this. --- lib/libalpm/alpm.h | 2 ++ lib/libalpm/error.c | 2 ++ lib/libalpm/util.c | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 96e5e643..f72d61a9 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -308,6 +308,8 @@ typedef enum _alpm_errno_t { /** Files conflict */ ALPM_ERR_FILE_CONFLICTS, /* Misc */ + /** Download setup failed */ + ALPM_ERR_RETRIEVE_PREPARE, /** Download failed */ ALPM_ERR_RETRIEVE, /** Invalid Regex */ diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c index 58842eac..ca97d884 100644 --- a/lib/libalpm/error.c +++ b/lib/libalpm/error.c @@ -138,6 +138,8 @@ const char SYMEXPORT *alpm_strerror(alpm_errno_t err) case ALPM_ERR_FILE_CONFLICTS: return _("conflicting files"); /* Miscellaneous */ + case ALPM_ERR_RETRIEVE_PREPARE: + return _("failed to initialize download"); case ALPM_ERR_RETRIEVE: return _("failed to retrieve some files"); case ALPM_ERR_INVALID_REGEX: diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 058bb77f..6d486d4c 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -974,7 +974,7 @@ char *_alpm_temporary_download_dir_setup(alpm_handle_t *handle, const char *dir) _("failed to get download user '%s': %s\n"), user, strerror(errno)); } - RET_ERR(handle, ALPM_ERR_RETRIEVE, NULL); + RET_ERR(handle, ALPM_ERR_RETRIEVE_PREPARE, NULL); } } @@ -988,7 +988,7 @@ char *_alpm_temporary_download_dir_setup(alpm_handle_t *handle, const char *dir) _("failed to create temporary download directory %s: %s\n"), newdir, strerror(errno)); free(newdir); - RET_ERR(handle, ALPM_ERR_RETRIEVE, NULL); + RET_ERR(handle, ALPM_ERR_RETRIEVE_PREPARE, NULL); } if(pw != NULL) { if(chown(newdir, pw->pw_uid, pw->pw_gid) == -1) { @@ -996,7 +996,7 @@ char *_alpm_temporary_download_dir_setup(alpm_handle_t *handle, const char *dir) _("failed to chown temporary download directory %s: %s\n"), newdir, strerror(errno)); free(newdir); - RET_ERR(handle, ALPM_ERR_RETRIEVE, NULL); + RET_ERR(handle, ALPM_ERR_RETRIEVE_PREPARE, NULL); } } newdir[newdirlen-2] = '/';