From 2bb0bae9b94751bdc6d0c1558591665895197ad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B5=AB=E7=84=B6?= Date: Mon, 13 Jan 2025 17:28:06 +0800 Subject: [PATCH] Skip check blocks when verify base commit --- server/gc/gc-core.c | 3 ++- server/gc/verify.c | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/gc/gc-core.c b/server/gc/gc-core.c index c4e6bb5a..897c86a4 100644 --- a/server/gc/gc-core.c +++ b/server/gc/gc-core.c @@ -170,7 +170,7 @@ fs_callback (SeafFSManager *mgr, // If traversing the base_commit, only the fs objects need to be retained, while the block does not. // This is because only the fs objects are needed when merging virtual repo. - if (data->repo->is_virtual && data->traverse_base_commit) { + if (data->traverse_base_commit) { return TRUE; } @@ -437,6 +437,7 @@ populate_gc_index_for_repo (GCData *data, SeafDBTrans *trans) traverse_commit, data, FALSE); + data->traverse_base_commit = FALSE; seaf_virtual_repo_info_free (vinfo); if (!res) { seaf_warning ("Failed to traverse base commit %s for virtual repo %s.\n", vinfo->base_commit, repo_id); diff --git a/server/gc/verify.c b/server/gc/verify.c index 9347557b..67bf9219 100644 --- a/server/gc/verify.c +++ b/server/gc/verify.c @@ -7,6 +7,7 @@ typedef struct VerifyData { gint64 truncate_time; gboolean traversed_head; GHashTable *exist_blocks; + gboolean traverse_base_commit; } VerifyData; static int @@ -47,6 +48,10 @@ fs_callback (SeafFSManager *mgr, { VerifyData *data = user_data; + if (data->traverse_base_commit) { + return TRUE; + } + if (type == SEAF_METADATA_TYPE_FILE && check_blocks (data, obj_id) < 0) return FALSE; @@ -100,6 +105,8 @@ verify_virtual_repos (VerifyData *data) return 0; } + data->traverse_base_commit = TRUE; + GList *vrepo_ids = NULL, *ptr; char *repo_id; SeafVirtRepo *vinfo; @@ -128,6 +135,7 @@ verify_virtual_repos (VerifyData *data) goto out; } } + data->traverse_base_commit = FALSE; out: string_list_free (vrepo_ids);