From 91007791cd60442c9c8f81009911281fedea0ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E8=B5=AB=E7=84=B6?= Date: Fri, 10 Jan 2025 17:21:14 +0800 Subject: [PATCH] Don't retain when traverse base commit --- fileserver/repomgr/repomgr.go | 1 + server/gc/gc-core.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/fileserver/repomgr/repomgr.go b/fileserver/repomgr/repomgr.go index d70c5a39..4c8878e3 100644 --- a/fileserver/repomgr/repomgr.go +++ b/fileserver/repomgr/repomgr.go @@ -235,6 +235,7 @@ func GetEx(id string) *Repo { } if originRepoID.Valid { repo.VirtualInfo = new(VRepoInfo) + repo.VirtualInfo.RepoID = id repo.VirtualInfo.OriginRepoID = originRepoID.String repo.StoreID = originRepoID.String diff --git a/server/gc/gc-core.c b/server/gc/gc-core.c index 7fb0c823..c4e6bb5a 100644 --- a/server/gc/gc-core.c +++ b/server/gc/gc-core.c @@ -95,6 +95,8 @@ typedef struct { SeafDBTrans *trans; gint64 keep_alive_last_time; gint64 keep_alive_obj_counter; + + gboolean traverse_base_commit; } GCData; static int @@ -166,6 +168,12 @@ fs_callback (SeafFSManager *mgr, add_fs_to_index(data, obj_id); + // 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) { + return TRUE; + } + if (type == SEAF_METADATA_TYPE_FILE && add_blocks_to_index (mgr, data, obj_id) < 0) return FALSE; @@ -422,6 +430,7 @@ populate_gc_index_for_repo (GCData *data, SeafDBTrans *trans) if (!vinfo) { continue; } + data->traverse_base_commit = TRUE; res = seaf_commit_manager_traverse_commit_tree (seaf->commit_mgr, repo->store_id, repo->version, vinfo->base_commit,