From be0dc71553d2bb3aa26e34eba973be3b428d7d18 Mon Sep 17 00:00:00 2001 From: William Douglas Date: Thu, 28 Mar 2024 11:57:23 -0700 Subject: [PATCH] Cleanup unused code The remove_files_in_manifest_from_fs function isn't used and was a user of a rather dangerous recursive remove function. Get rid of it to avoid potential confusion. Signed-off-by: William Douglas --- src/swupd.h | 1 - src/swupd_lib/manifest.c | 27 --------------------------- 2 files changed, 28 deletions(-) diff --git a/src/swupd.h b/src/swupd.h index 2f3a8b3bf..ac036f19a 100644 --- a/src/swupd.h +++ b/src/swupd.h @@ -264,7 +264,6 @@ extern bool verify_file(struct file *file, char *filename); extern bool verify_file_lazy(char *filename); extern int verify_bundle_hash(struct manifest *manifest, struct file *bundle); void free_file_data(void *data); -void remove_files_in_manifest_from_fs(struct manifest *m); void deduplicate_files_from_manifest(struct manifest **m1, struct manifest *m2); extern struct file *mom_search_bundle(struct manifest *mom, const char *bundlename); extern struct file *search_file_in_manifest(struct manifest *manifest, const char *filename); diff --git a/src/swupd_lib/manifest.c b/src/swupd_lib/manifest.c index 9b3ed9be3..cb55041a3 100644 --- a/src/swupd_lib/manifest.c +++ b/src/swupd_lib/manifest.c @@ -848,33 +848,6 @@ void populate_file_struct(struct file *file, char *filename) return; } -/* Iterate m file list and remove from filesystem each file/directory */ -void remove_files_in_manifest_from_fs(struct manifest *m) -{ - struct list *iter = NULL; - struct file *file = NULL; - char *fullfile = NULL; - int count = list_len(m->files); - - iter = list_head(m->files); - while (iter) { - file = iter->data; - iter = iter->next; - string_or_die(&fullfile, "%s/%s", globals.path_prefix, file->filename); - int err = sys_rm_recursive(fullfile); - if (err != 0 && err != -ENOENT) { - /* if an error is returned it means there was an issue deleting the - * file or directory, in that case decrease the counter of deleted - * files. - * Note: If a file didn't exist it will still be counted as deleted, - * this is a limitation */ - count--; - } - FREE(fullfile); - } - info("Total deleted files: %i\n", count); -} - /* free all files found in m1 that happens to be * duplicated on m2. *