diff --git a/common/rpc-service.c b/common/rpc-service.c index b14a9d5..f5691e5 100644 --- a/common/rpc-service.c +++ b/common/rpc-service.c @@ -5110,4 +5110,28 @@ seafile_get_trash_repo_owner (const char *repo_id, GError **error) return seaf_get_trash_repo_owner (repo_id); } +int +seafile_mkdir_with_parents (const char *repo_id, const char *parent_dir, + const char *new_dir_path, const char *user, + GError **error) +{ + if (!repo_id || !parent_dir || !new_dir_path || !user) { + g_set_error (error, 0, SEAF_ERR_BAD_ARGS, "Argument should not be null"); + return -1; + } + + if (!is_uuid_valid (repo_id)) { + g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Invalid repo id"); + return -1; + } + + if (seaf_repo_manager_mkdir_with_parents (seaf->repo_mgr, repo_id, + parent_dir, new_dir_path, + user, error) < 0) { + return -1; + } + + return 0; +} + #endif /* SEAFILE_SERVER */ diff --git a/include/seafile-rpc.h b/include/seafile-rpc.h index 916d1c7..13e1abd 100644 --- a/include/seafile-rpc.h +++ b/include/seafile-rpc.h @@ -730,6 +730,10 @@ int seafile_post_dir (const char *repo_id, const char *parent_dir, const char *new_dir_name, const char *user, GError **error); +int +seafile_mkdir_with_parents (const char *repo_id, const char *parent_dir, + const char *new_dir_path, const char *user, + GError **error); /** * delete a file/directory from the repo on server. diff --git a/python/seafile/rpcclient.py b/python/seafile/rpcclient.py index 320c078..3e519b2 100644 --- a/python/seafile/rpcclient.py +++ b/python/seafile/rpcclient.py @@ -968,3 +968,8 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase): @searpc_func("string", ["string"]) def get_trash_repo_owner(repo_id): pass + + @searpc_func("int", ["string", "string", "string", "string"]) + def seafile_mkdir_with_parents (repo_id, parent_dir, relative_path, username): + pass + mkdir_with_parents = seafile_mkdir_with_parents diff --git a/python/seaserv/api.py b/python/seaserv/api.py index 760c471..84a82e8 100644 --- a/python/seaserv/api.py +++ b/python/seaserv/api.py @@ -678,6 +678,9 @@ class SeafileAPI(object): def get_trash_repo_owner (self, repo_id): return seafserv_threaded_rpc.get_trash_repo_owner(repo_id) + def mkdir_with_parents (self, repo_id, parent_dir, relative_path, username): + return seafserv_threaded_rpc.mkdir_with_parents(repo_id, parent_dir, relative_path, username) + seafile_api = SeafileAPI() class CcnetAPI(object): diff --git a/server/seaf-server.c b/server/seaf-server.c index ae17f42..c70cf6f 100644 --- a/server/seaf-server.c +++ b/server/seaf-server.c @@ -233,6 +233,11 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode) "seafile_post_dir", searpc_signature_int__string_string_string_string()); + searpc_server_register_function ("seafserv-threaded-rpcserver", + seafile_mkdir_with_parents, + "seafile_mkdir_with_parents", + searpc_signature_int__string_string_string_string()); + searpc_server_register_function ("seafserv-threaded-rpcserver", seafile_del_file, "seafile_del_file",