bin/xbps-remove: error logging for cache cleaning

Fixes #357
This commit is contained in:
Duncan Overbruck 2021-12-25 15:16:02 +01:00
parent 6e3309b564
commit 4fb621c6c5
No known key found for this signature in database
GPG Key ID: 335C1D17EC3D6E35

View File

@ -70,23 +70,29 @@ cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj,
repo_pkgd = xbps_rpool_get_pkg(xhp, pkgver); repo_pkgd = xbps_rpool_get_pkg(xhp, pkgver);
free(pkgver); free(pkgver);
if (repo_pkgd) { if (repo_pkgd) {
int r;
xbps_dictionary_get_cstring_nocopy(repo_pkgd, xbps_dictionary_get_cstring_nocopy(repo_pkgd,
"filename-sha256", &rsha256); "filename-sha256", &rsha256);
if (xbps_file_sha256_check(binpkg, rsha256) == 0) { r = xbps_file_sha256_check(binpkg, rsha256);
if (r == 0) {
/* hash matched */ /* hash matched */
return 0; return 0;
} }
if (r != ERANGE) {
xbps_error_printf("Failed to checksum `%s': %s\n", binpkg, strerror(r));
return 0;
}
} }
binpkgsig = xbps_xasprintf("%s.sig", binpkg); binpkgsig = xbps_xasprintf("%s.sig", binpkg);
if (!drun && unlink(binpkg) == -1) { if (!drun && unlink(binpkg) == -1) {
fprintf(stderr, "Failed to remove `%s': %s\n", xbps_error_printf("Failed to remove `%s': %s\n",
binpkg, strerror(errno)); binpkg, strerror(errno));
} else { } else {
printf("Removed %s from cachedir (obsolete)\n", binpkg); printf("Removed %s from cachedir (obsolete)\n", binpkg);
} }
if (!drun && unlink(binpkgsig) == -1) { if (!drun && unlink(binpkgsig) == -1) {
if (errno != ENOENT) { if (errno != ENOENT) {
fprintf(stderr, "Failed to remove `%s': %s\n", xbps_error_printf("Failed to remove `%s': %s\n",
binpkgsig, strerror(errno)); binpkgsig, strerror(errno));
} }
} }