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.
This commit is contained in:
morganamilo 2025-05-20 13:45:02 +01:00
parent a1ff7d8c72
commit 3612510ee0
No known key found for this signature in database
GPG key ID: E48D0A8326DE47C5
3 changed files with 7 additions and 3 deletions

View file

@ -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 */

View file

@ -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:

View file

@ -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] = '/';