diff mbox series

[OpenWrt-Devel] opkg: remove inexistent files from list only

Message ID 20200404113015.17863-1-peter.stadler@student.uibk.ac.at
State New
Headers show
Series [OpenWrt-Devel] opkg: remove inexistent files from list only | expand

Commit Message

Peter Stadler April 4, 2020, 11:30 a.m. UTC
This avoids misleading messages for files that are deleted already
(by the user or by remove_obsolesced_files), e.g. for conffiles:
  * file_sha256sum_alloc: Failed to open file …
  Not deleting modified conffile …
(This statement is false for obsolete files as opkg deleted them.)

Signed-off-by: Peter Stadler <peter.stadler@student.uibk.ac.at>
---
 libopkg/opkg_remove.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/libopkg/opkg_remove.c b/libopkg/opkg_remove.c
index 96ca558..a9c7d5a 100644
--- a/libopkg/opkg_remove.c
+++ b/libopkg/opkg_remove.c
@@ -355,6 +355,12 @@  void remove_data_files_and_list(pkg_t * pkg)
 	     iter = str_list_next(installed_files, iter)) {
 		file_name = (char *)iter->data;
 
+		if (!file_exists(file_name)) {
+			/* File deleted by user or remove_obsolesced_files(). */
+			file_hash_remove(file_name);
+			continue;
+		}
+
 		owner = file_hash_get_file_owner(file_name);
 		if (owner != pkg)
 			/* File may have been claimed by another package. */