mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-08 02:38:54 +00:00
Support pagination in listing file histories.
Keep at least 2 versions (if exists) when listing file history.
This commit is contained in:
@@ -376,6 +376,7 @@ seaf_commit_manager_traverse_commit_tree_with_limit (SeafCommitManager *mgr,
|
||||
CommitTraverseFunc func,
|
||||
int limit,
|
||||
void *data,
|
||||
char **next_start_commit,
|
||||
gboolean skip_errors)
|
||||
{
|
||||
SeafCommit *commit;
|
||||
@@ -389,6 +390,7 @@ seaf_commit_manager_traverse_commit_tree_with_limit (SeafCommitManager *mgr,
|
||||
commit = seaf_commit_manager_get_commit (mgr, repo_id, version, head);
|
||||
if (!commit) {
|
||||
seaf_warning ("Failed to find commit %s.\n", head);
|
||||
g_hash_table_destroy (commit_hash);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -413,12 +415,6 @@ seaf_commit_manager_traverse_commit_tree_with_limit (SeafCommitManager *mgr,
|
||||
}
|
||||
}
|
||||
|
||||
/* Stop when limit is reached. If limit < 0, there is no limit; */
|
||||
if (limit > 0 && ++count == limit) {
|
||||
seaf_commit_unref (commit);
|
||||
break;
|
||||
}
|
||||
|
||||
if (stop) {
|
||||
seaf_commit_unref (commit);
|
||||
/* stop traverse down from this commit,
|
||||
@@ -448,6 +444,26 @@ seaf_commit_manager_traverse_commit_tree_with_limit (SeafCommitManager *mgr,
|
||||
}
|
||||
}
|
||||
seaf_commit_unref (commit);
|
||||
|
||||
/* Stop when limit is reached and don't stop at unmerged branch.
|
||||
* If limit < 0, there is no limit;
|
||||
*/
|
||||
if (limit > 0 && ++count >= limit && (!list || !list->next)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* two scenarios:
|
||||
* 1. list is empty, indicate scan end
|
||||
* 2. list only have one commit, as start for next scan
|
||||
*/
|
||||
if (list) {
|
||||
commit = list->data;
|
||||
if (next_start_commit) {
|
||||
*next_start_commit= g_strdup (commit->commit_id);
|
||||
}
|
||||
seaf_commit_unref (commit);
|
||||
list = g_list_delete_link (list, list);
|
||||
}
|
||||
|
||||
out:
|
||||
|
Reference in New Issue
Block a user