From 4fb621c6c51e42a93fe8cdbc7b664ceedec72a26 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sat, 25 Dec 2021 15:16:02 +0100 Subject: [PATCH] bin/xbps-remove: error logging for cache cleaning Fixes #357 --- bin/xbps-remove/clean-cache.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bin/xbps-remove/clean-cache.c b/bin/xbps-remove/clean-cache.c index 43ff6057..8c82b1b0 100644 --- a/bin/xbps-remove/clean-cache.c +++ b/bin/xbps-remove/clean-cache.c @@ -70,23 +70,29 @@ cleaner_cb(struct xbps_handle *xhp, xbps_object_t obj, repo_pkgd = xbps_rpool_get_pkg(xhp, pkgver); free(pkgver); if (repo_pkgd) { + int r; xbps_dictionary_get_cstring_nocopy(repo_pkgd, "filename-sha256", &rsha256); - if (xbps_file_sha256_check(binpkg, rsha256) == 0) { + r = xbps_file_sha256_check(binpkg, rsha256); + if (r == 0) { /* hash matched */ 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); 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)); } else { printf("Removed %s from cachedir (obsolete)\n", binpkg); } if (!drun && unlink(binpkgsig) == -1) { if (errno != ENOENT) { - fprintf(stderr, "Failed to remove `%s': %s\n", + xbps_error_printf("Failed to remove `%s': %s\n", binpkgsig, strerror(errno)); } }