1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-09-15 22:59:43 +00:00

Add search_files_by_path RPC (#599)

Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
feiniks
2023-02-25 11:24:50 +08:00
committed by GitHub
parent 766d716c6a
commit 499e8e8d17
7 changed files with 44 additions and 9 deletions

View File

@@ -3174,9 +3174,10 @@ search_files_recursive (SeafFSManager *mgr,
}
GList *
seaf_fs_manager_search_files (SeafFSManager *mgr,
const char *repo_id,
const char *str)
seaf_fs_manager_search_files_by_path (SeafFSManager *mgr,
const char *repo_id,
const char *path,
const char *str)
{
GList *file_list = NULL;
SeafCommit *head = NULL;
@@ -3193,8 +3194,20 @@ seaf_fs_manager_search_files (SeafFSManager *mgr,
goto out;
}
search_files_recursive (mgr, repo->store_id, "", head->root_id,
str, repo->version, &file_list);
if (!path || g_strcmp0 (path, "/") == 0) {
search_files_recursive (mgr, repo->store_id, "", head->root_id,
str, repo->version, &file_list);
} else {
char *dir_id = seaf_fs_manager_get_seafdir_id_by_path (mgr, repo->store_id, repo->version,
head->root_id, path, NULL);
if (!dir_id) {
seaf_warning ("Path %s doesn't exist or is not a dir in repo %.10s.\n", path, repo->store_id);
goto out;
}
search_files_recursive (mgr, repo->store_id, path, dir_id,
str, repo->version, &file_list);
g_free (dir_id);
}
out:
seaf_repo_unref (repo);