Skip to content

Commit

Permalink
Cleanup unused code
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
bryteise committed Apr 4, 2024
1 parent bf53867 commit be0dc71
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 28 deletions.
1 change: 0 additions & 1 deletion src/swupd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 0 additions & 27 deletions src/swupd_lib/manifest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit be0dc71

Please sign in to comment.