mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-05 01:11:05 +00:00
Add search_files_by_path RPC (#599)
Co-authored-by: 杨赫然 <heran.yang@seafile.com>
This commit is contained in:
@@ -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);
|
||||
|
@@ -437,8 +437,9 @@ seaf_fs_manager_get_file_count_info_by_path (SeafFSManager *mgr,
|
||||
GError **error);
|
||||
|
||||
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);
|
||||
|
||||
#endif
|
||||
|
@@ -4516,13 +4516,19 @@ seafile_get_repo_status(const char *repo_id, GError **error)
|
||||
|
||||
GList *
|
||||
seafile_search_files (const char *repo_id, const char *str, GError **error)
|
||||
{
|
||||
return seafile_search_files_by_path (repo_id, NULL, str, error);
|
||||
}
|
||||
|
||||
GList *
|
||||
seafile_search_files_by_path (const char *repo_id, const char *path, const char *str, GError **error)
|
||||
{
|
||||
if (!is_uuid_valid (repo_id)) {
|
||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid repo id");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
GList *file_list = seaf_fs_manager_search_files (seaf->fs_mgr, repo_id, str);
|
||||
GList *file_list = seaf_fs_manager_search_files_by_path (seaf->fs_mgr, repo_id, path, str);
|
||||
GList *ret = NULL, *ptr;
|
||||
|
||||
for (ptr = file_list; ptr; ptr=ptr->next) {
|
||||
|
@@ -1141,6 +1141,9 @@ seafile_pop_event(const char *channel, GError **error);
|
||||
GList *
|
||||
seafile_search_files (const char *repo_id, const char *str, GError **error);
|
||||
|
||||
GList *
|
||||
seafile_search_files_by_path (const char *repo_id, const char *path, const char *str, GError **error);
|
||||
|
||||
/*Following is ccnet rpc*/
|
||||
int
|
||||
ccnet_rpc_add_emailuser (const char *email, const char *passwd,
|
||||
|
@@ -817,6 +817,10 @@ class SeafServerThreadedRpcClient(NamedPipeClient):
|
||||
def search_files(self, repo_id, search_str):
|
||||
pass
|
||||
|
||||
@searpc_func("objlist", ["string", "string", "string"])
|
||||
def search_files_by_path(self, repo_id, path, search_str):
|
||||
pass
|
||||
|
||||
#user management
|
||||
@searpc_func("int", ["string", "string", "int", "int"])
|
||||
def add_emailuser(self, email, passwd, is_staff, is_active):
|
||||
|
@@ -857,6 +857,9 @@ class SeafileAPI(object):
|
||||
def search_files(self, repo_id, search_str):
|
||||
return seafserv_threaded_rpc.search_files(repo_id, search_str)
|
||||
|
||||
def search_files_by_path (self, repo_id, path, search_str):
|
||||
return seafserv_threaded_rpc.search_files_by_path(repo_id, path, search_str)
|
||||
|
||||
seafile_api = SeafileAPI()
|
||||
|
||||
class CcnetAPI(object):
|
||||
|
@@ -344,6 +344,11 @@ static void start_rpc_service (const char *seafile_dir,
|
||||
"search_files",
|
||||
searpc_signature_objlist__string_string());
|
||||
|
||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||
seafile_search_files_by_path,
|
||||
"search_files_by_path",
|
||||
searpc_signature_objlist__string_string_string());
|
||||
|
||||
/* share repo to user */
|
||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||
seafile_add_share,
|
||||
|
Reference in New Issue
Block a user