1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-09-08 02:38:54 +00:00

Don't restore repo when failed to get head commit and fix a memory leak (#532)

This commit is contained in:
feiniks
2021-12-18 10:26:35 +08:00
committed by GitHub
parent 2931328df6
commit 62fc07fe2e
2 changed files with 8 additions and 0 deletions

View File

@@ -166,6 +166,7 @@ seaf_commit_free (SeafCommit *commit)
if (commit->repo_desc) g_free (commit->repo_desc); if (commit->repo_desc) g_free (commit->repo_desc);
if (commit->device_name) g_free (commit->device_name); if (commit->device_name) g_free (commit->device_name);
if (commit->repo_category) g_free (commit->repo_category); if (commit->repo_category) g_free (commit->repo_category);
if (commit->salt) g_free (commit->salt);
g_free (commit->client_version); g_free (commit->client_version);
g_free (commit->magic); g_free (commit->magic);
g_free (commit->random_key); g_free (commit->random_key);

View File

@@ -2849,6 +2849,13 @@ seaf_repo_manager_restore_repo_from_trash (SeafRepoManager *mgr,
head_id = seafile_trash_repo_get_head_id (repo); head_id = seafile_trash_repo_get_head_id (repo);
commit = seaf_commit_manager_get_commit_compatible (seaf->commit_mgr, commit = seaf_commit_manager_get_commit_compatible (seaf->commit_mgr,
repo_id, head_id); repo_id, head_id);
if (!commit) {
seaf_warning ("Commit %.8s of repo %.8s not found.\n", repo_id, head_id);
seaf_db_rollback (trans);
seaf_db_trans_close (trans);
ret = -1;
goto out;
}
ret = seaf_db_trans_query (trans, ret = seaf_db_trans_query (trans,
"INSERT INTO RepoInfo (repo_id, name, update_time, version, is_encrypted, last_modifier) VALUES (?, ?, ?, ?, ?, ?)", "INSERT INTO RepoInfo (repo_id, name, update_time, version, is_encrypted, last_modifier) VALUES (?, ?, ?, ?, ?, ?)",
6, "string", repo_id, 6, "string", repo_id,