[pacman-dev] [PATCH] libalpm: Check return errors while deleting files

Hamza Mogni hamzamogni5 at gmail.com
Mon Jan 20 20:03:02 UTC 2020


I found this TODO while browsing pacman's source code, tried fixing it
by checking returned errors while deleting packages files and logging
accordingly.

This is my first time editing code and submitting a patch; SORRY if I
did anything dumb!

Signed-off-by: Hamza Mogni <hamzamogni5 at gmail.com>
---
 lib/libalpm/remove.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 9030bfee..4a19c718 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -707,7 +707,12 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
 
 	if(!(handle->trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
 		/* TODO check returned errors if any */
-		remove_package_files(handle, oldpkg, newpkg, targ_count, pkg_count);
+		int err = remove_package_files(handle, oldpkg, newpkg, targ_count, pkg_count);
+		if (err == -1) {
+		    _alpm_log(handle, ALPM_LOG_ERROR, "alpm lacks permission to delete all files");
+		} else if (err > 0) {
+			_alpm_log(handle, ALPM_LOG_ERROR, "failed to delete %d files", err);
+		}
 	}
 
 	if(!newpkg) {
-- 
2.25.0


More information about the pacman-dev mailing list