static int verify_repo (SeafRepo *repo) { GList *branches, *ptr; SeafBranch *branch; int ret = 0; VerifyData data = {0}; data.truncate_time = seaf_repo_manager_get_repo_truncate_time (repo->manager, repo->id); branches = seaf_branch_manager_get_branch_list (seaf->branch_mgr, repo->id); if (branches == NULL) { seaf_warning ("[GC] Failed to get branch list of repo %s.\n", repo->id); return -1; } for (ptr = branches; ptr != NULL; ptr = ptr->next) { branch = ptr->data; gboolean res = seaf_commit_manager_traverse_commit_tree (seaf->commit_mgr, branch->commit_id, traverse_commit, &data); seaf_branch_unref (branch); if (!res) { ret = -1; break; } } g_list_free (branches); return ret; }
static int validate_repo(SeafRepo *repo) { if(!repo) return -1; printf (">>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" "Checking for repo %s (%s)\n" , repo->name, repo->id); GList *branch_list = seaf_branch_manager_get_branch_list(seaf->branch_mgr, repo->id); if (!branch_list) { g_warning ("Failed to get branch list of repo %s\n", repo->id); return -1; } /* Check whether the "local" branch exists */ GList *ptr = branch_list; while (ptr) { SeafBranch *branch = ptr->data; if (g_strcmp0(branch->name, "local") == 0) break; ptr = ptr->next; } if (!ptr) { /* No "local" branch */ g_warning ("[ERROR] The branch \"local\" doesn't exist for repo %s\n", repo->id); g_list_free (branch_list); return -1; } while (ptr) { SeafBranch *branch = ptr->data; ptr = ptr->next; if (validate_branch(branch) < 0 && !force_continue) { g_list_free (branch_list); return -1; } } g_list_free (branch_list); if (validate_repo_index(repo) < 0) return -1; if (validate_repo_token((const char*)repo->id) < 0) return -1; printf ("<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n"); printf ("Done for repo %s\n", repo->id); return 0; }
GList * seaf_repo_get_commits (SeafRepo *repo) { GList *branches; GList *ptr; SeafBranch *branch; GList *commits = NULL; branches = seaf_branch_manager_get_branch_list (seaf->branch_mgr, repo->id); if (branches == NULL) { g_warning ("Failed to get branch list of repo %s.\n", repo->id); return NULL; } for (ptr = branches; ptr != NULL; ptr = ptr->next) { branch = ptr->data; gboolean res = seaf_commit_manager_traverse_commit_tree (seaf->commit_mgr, repo->id, repo->version, branch->commit_id, collect_commit, &commits, FALSE); if (!res) { for (ptr = commits; ptr != NULL; ptr = ptr->next) seaf_commit_unref ((SeafCommit *)(ptr->data)); g_list_free (commits); goto out; } } commits = g_list_reverse (commits); out: for (ptr = branches; ptr != NULL; ptr = ptr->next) { seaf_branch_unref ((SeafBranch *)ptr->data); } return commits; }