Skip to content

Commit

Permalink
Fix load mini repo info.
Browse files Browse the repository at this point in the history
  • Loading branch information
ly1217 committed Nov 2, 2019
1 parent 6a428da commit 06f8661
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/commit-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ seaf_commit_free (SeafCommit *commit)
g_free (commit->client_version);
g_free (commit->magic);
g_free (commit->random_key);
g_free (commit->salt);
g_free (commit);
}

Expand Down
26 changes: 24 additions & 2 deletions server/repo-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,28 @@ collect_repos_fill_size_commit (SeafDBRow *row, void *data)
return TRUE;
}

/* RepoInfo upgraded two times in history,
* the fist time 'repo_name' column was added
* and the second time column 'last_modifier'
* is added, so the default value NULL should be considered.
*/
static gboolean
mini_repo_incomplete (SeafRepo *repo)
{
if (!repo->name || !repo->last_modifier) {
if (repo->name) {
g_free (repo->name);
}
if (repo->last_modifier) {
g_free (repo->last_modifier);
}

return TRUE;
}

return FALSE;
}

GList *
seaf_repo_manager_get_repos_by_owner (SeafRepoManager *mgr,
const char *email,
Expand Down Expand Up @@ -2318,7 +2340,7 @@ seaf_repo_manager_get_repos_by_owner (SeafRepoManager *mgr,
for (ptr = repo_list; ptr; ptr = ptr->next) {
repo = ptr->data;
if (ret_corrupted) {
if (!repo->is_corrupted && (!repo->name || !repo->last_modifier)) {
if (!repo->is_corrupted && mini_repo_incomplete (repo)) {
load_mini_repo (mgr, repo);
if (!repo->is_corrupted)
set_repo_commit_to_db (repo->id, repo->name, repo->last_modify,
Expand All @@ -2330,7 +2352,7 @@ seaf_repo_manager_get_repos_by_owner (SeafRepoManager *mgr,
seaf_repo_unref (repo);
continue;
}
if (!repo->name || !repo->last_modifier) {
if (mini_repo_incomplete (repo)) {
load_mini_repo (mgr, repo);
if (!repo->is_corrupted)
set_repo_commit_to_db (repo->id, repo->name, repo->last_modify,
Expand Down

0 comments on commit 06f8661

Please sign in to comment.