Skip to content

Commit

Permalink
Skip check blocks when verify base commit
Browse files Browse the repository at this point in the history
  • Loading branch information
杨赫然 committed Jan 13, 2025
1 parent 9100779 commit 2bb0bae
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion server/gc/gc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 8 additions & 0 deletions server/gc/verify.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ typedef struct VerifyData {
gint64 truncate_time;
gboolean traversed_head;
GHashTable *exist_blocks;
gboolean traverse_base_commit;
} VerifyData;

static int
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -128,6 +135,7 @@ verify_virtual_repos (VerifyData *data)
goto out;
}
}
data->traverse_base_commit = FALSE;

out:
string_list_free (vrepo_ids);
Expand Down

0 comments on commit 2bb0bae

Please sign in to comment.