From 83a9c3955675cd103cdf1e3fe3858318484279db Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Tue, 14 Nov 2017 14:15:13 -0800 Subject: [PATCH] Prune orphaned rename files from manifest When renamed-to files are deleted or are renamed again, the original renamed-from file is orphaned as it has no renamed-to peer. Prune these from the manifests by checking if the rename_peer field is NULL. Signed-off-by: Matthew Johnson --- src/manifest.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/manifest.c b/src/manifest.c index b7bf3f8..f59b294 100644 --- a/src/manifest.c +++ b/src/manifest.c @@ -1045,6 +1045,14 @@ int prune_manifest(struct manifest *manifest) next = g_list_next(list); file = list->data; + /* if the file is marked as deleted and renamed it is a renamed_from + * file. If the rename_peer field is still NULL then it has been + * orphaned. Prune these files */ + if (file->is_deleted && file->is_rename && !file->rename_peer) { + manifest->files = g_list_delete_link(manifest->files, list); + manifest->count--; + } + if (OS_IS_STATELESS && (!file->is_deleted) && (file->is_config)) { // toward being a stateless OS LOG(file, "Skipping config file in manifest write", "component %s", manifest->component);