mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-02 07:54:27 +00:00
return vrepo_id when share subdir
This commit is contained in:
@@ -2437,7 +2437,7 @@ seafile_list_repo_shared_to (const char *from_user, const char *repo_id,
|
|||||||
error);
|
error);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
char *
|
||||||
seafile_share_subdir_to_user (const char *repo_id,
|
seafile_share_subdir_to_user (const char *repo_id,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *owner,
|
const char *owner,
|
||||||
@@ -2449,43 +2449,43 @@ seafile_share_subdir_to_user (const char *repo_id,
|
|||||||
if (is_empty_string (repo_id) || !is_uuid_valid (repo_id)) {
|
if (is_empty_string (repo_id) || !is_uuid_valid (repo_id)) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid repo_id parameter");
|
"Invalid repo_id parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_empty_string (path) || strcmp (path, "/") == 0) {
|
if (is_empty_string (path) || strcmp (path, "/") == 0) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid path parameter");
|
"Invalid path parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_empty_string (owner)) {
|
if (is_empty_string (owner)) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid owner parameter");
|
"Invalid owner parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_empty_string (share_user)) {
|
if (is_empty_string (share_user)) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid share_user parameter");
|
"Invalid share_user parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp (owner, share_user) == 0) {
|
if (strcmp (owner, share_user) == 0) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Can't share subdir to myself");
|
"Can't share subdir to myself");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_permission_valid (permission)) {
|
if (!is_permission_valid (permission)) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid permission parameter");
|
"Invalid permission parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *real_path;
|
char *real_path;
|
||||||
char *vrepo_name;
|
char *vrepo_name;
|
||||||
char *vrepo_id;
|
char *vrepo_id;
|
||||||
int ret = 0;
|
char *ret = NULL;
|
||||||
|
|
||||||
real_path = format_dir_path (path);
|
real_path = format_dir_path (path);
|
||||||
// Use subdir name as virtual repo name and description
|
// Use subdir name as virtual repo name and description
|
||||||
@@ -2494,18 +2494,18 @@ seafile_share_subdir_to_user (const char *repo_id,
|
|||||||
repo_id, real_path,
|
repo_id, real_path,
|
||||||
vrepo_name, vrepo_name,
|
vrepo_name, vrepo_name,
|
||||||
owner, passwd, error);
|
owner, passwd, error);
|
||||||
if (!vrepo_id) {
|
if (!vrepo_id)
|
||||||
ret = -1;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
ret = seaf_share_manager_add_share (seaf->share_mgr, vrepo_id, owner,
|
int result = seaf_share_manager_add_share (seaf->share_mgr, vrepo_id, owner,
|
||||||
share_user, permission);
|
share_user, permission);
|
||||||
if (ret < 0) {
|
if (result < 0) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||||
"Failed to share subdir to user");
|
"Failed to share subdir to user");
|
||||||
}
|
|
||||||
g_free (vrepo_id);
|
g_free (vrepo_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = vrepo_id;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (vrepo_name);
|
g_free (vrepo_name);
|
||||||
@@ -2733,7 +2733,7 @@ seafile_group_unshare_repo (const char *repo_id, int group_id,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
char *
|
||||||
seafile_share_subdir_to_group (const char *repo_id,
|
seafile_share_subdir_to_group (const char *repo_id,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *owner,
|
const char *owner,
|
||||||
@@ -2745,37 +2745,37 @@ seafile_share_subdir_to_group (const char *repo_id,
|
|||||||
if (is_empty_string (repo_id) || !is_uuid_valid (repo_id)) {
|
if (is_empty_string (repo_id) || !is_uuid_valid (repo_id)) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid repo_id parameter");
|
"Invalid repo_id parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_empty_string (path) || strcmp (path, "/") == 0) {
|
if (is_empty_string (path) || strcmp (path, "/") == 0) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid path parameter");
|
"Invalid path parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_empty_string (owner)) {
|
if (is_empty_string (owner)) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid owner parameter");
|
"Invalid owner parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (share_group < 0) {
|
if (share_group < 0) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid share_group parameter");
|
"Invalid share_group parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_permission_valid (permission)) {
|
if (!is_permission_valid (permission)) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
|
||||||
"Invalid permission parameter");
|
"Invalid permission parameter");
|
||||||
return -1;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *real_path;
|
char *real_path;
|
||||||
char *vrepo_name;
|
char *vrepo_name;
|
||||||
char *vrepo_id;
|
char *vrepo_id;
|
||||||
int ret = 0;
|
char* ret = NULL;
|
||||||
|
|
||||||
real_path = format_dir_path (path);
|
real_path = format_dir_path (path);
|
||||||
// Use subdir name as virtual repo name and description
|
// Use subdir name as virtual repo name and description
|
||||||
@@ -2784,18 +2784,18 @@ seafile_share_subdir_to_group (const char *repo_id,
|
|||||||
repo_id, real_path,
|
repo_id, real_path,
|
||||||
vrepo_name, vrepo_name,
|
vrepo_name, vrepo_name,
|
||||||
owner, passwd, error);
|
owner, passwd, error);
|
||||||
if (!vrepo_id) {
|
if (!vrepo_id)
|
||||||
ret = -1;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
|
|
||||||
ret = seaf_repo_manager_add_group_repo (seaf->repo_mgr, vrepo_id, share_group,
|
int result = seaf_repo_manager_add_group_repo (seaf->repo_mgr, vrepo_id, share_group,
|
||||||
owner, permission, error);
|
owner, permission, error);
|
||||||
if (ret < 0) {
|
if (result < 0) {
|
||||||
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
|
||||||
"Failed to share subdir to group");
|
"Failed to share subdir to group");
|
||||||
}
|
|
||||||
g_free (vrepo_id);
|
g_free (vrepo_id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = vrepo_id;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
g_free (vrepo_name);
|
g_free (vrepo_name);
|
||||||
|
@@ -505,7 +505,7 @@ seafile_get_checkout_task (const char *repo_id, GError **error);
|
|||||||
GList *
|
GList *
|
||||||
seafile_get_sync_task_list (GError **error);
|
seafile_get_sync_task_list (GError **error);
|
||||||
|
|
||||||
int
|
char *
|
||||||
seafile_share_subdir_to_user (const char *repo_id,
|
seafile_share_subdir_to_user (const char *repo_id,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *owner,
|
const char *owner,
|
||||||
@@ -550,7 +550,7 @@ int
|
|||||||
seafile_remove_share (const char *repo_id, const char *from_email,
|
seafile_remove_share (const char *repo_id, const char *from_email,
|
||||||
const char *to_email, GError **error);
|
const char *to_email, GError **error);
|
||||||
|
|
||||||
int
|
char *
|
||||||
seafile_share_subdir_to_group (const char *repo_id,
|
seafile_share_subdir_to_group (const char *repo_id,
|
||||||
const char *path,
|
const char *path,
|
||||||
const char *owner,
|
const char *owner,
|
||||||
|
@@ -52,6 +52,7 @@ func_table = [
|
|||||||
[ "string", ["string", "string", "string", "string", "int"] ],
|
[ "string", ["string", "string", "string", "string", "int"] ],
|
||||||
[ "string", ["string", "string", "string", "string", "string"] ],
|
[ "string", ["string", "string", "string", "string", "string"] ],
|
||||||
[ "string", ["string", "string", "string", "string", "string", "int"] ],
|
[ "string", ["string", "string", "string", "string", "string", "int"] ],
|
||||||
|
[ "string", ["string", "string", "string", "int", "string", "string"] ],
|
||||||
[ "string", ["string", "string", "string", "string", "string", "string", "int"] ],
|
[ "string", ["string", "string", "string", "string", "string", "string", "int"] ],
|
||||||
[ "string", ["string", "string", "string", "string", "string", "string", "int", "int"] ],
|
[ "string", ["string", "string", "string", "string", "string", "string", "int", "int"] ],
|
||||||
[ "string", ["string", "string", "string", "string", "string", "string"] ],
|
[ "string", ["string", "string", "string", "string", "string", "string"] ],
|
||||||
|
@@ -554,7 +554,7 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
|
|||||||
pass
|
pass
|
||||||
list_repo_shared_to = seafile_list_repo_shared_to
|
list_repo_shared_to = seafile_list_repo_shared_to
|
||||||
|
|
||||||
@searpc_func("int", ["string", "string", "string", "string", "string", "string"])
|
@searpc_func("string", ["string", "string", "string", "string", "string", "string"])
|
||||||
def share_subdir_to_user(repo_id, path, owner, share_user, permission, passwd):
|
def share_subdir_to_user(repo_id, path, owner, share_user, permission, passwd):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -611,7 +611,7 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
|
|||||||
pass
|
pass
|
||||||
get_shared_groups_for_subdir = seafile_get_shared_groups_for_subdir
|
get_shared_groups_for_subdir = seafile_get_shared_groups_for_subdir
|
||||||
|
|
||||||
@searpc_func("int", ["string", "string", "string", "int", "string", "string"])
|
@searpc_func("string", ["string", "string", "string", "int", "string", "string"])
|
||||||
def share_subdir_to_group(repo_id, path, owner, share_group, permission, passwd):
|
def share_subdir_to_group(repo_id, path, owner, share_group, permission, passwd):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@@ -379,7 +379,7 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
|
|||||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||||
seafile_share_subdir_to_user,
|
seafile_share_subdir_to_user,
|
||||||
"share_subdir_to_user",
|
"share_subdir_to_user",
|
||||||
searpc_signature_int__string_string_string_string_string_string());
|
searpc_signature_string__string_string_string_string_string_string());
|
||||||
|
|
||||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||||
seafile_unshare_subdir_for_user,
|
seafile_unshare_subdir_for_user,
|
||||||
@@ -408,7 +408,7 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
|
|||||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||||
seafile_share_subdir_to_group,
|
seafile_share_subdir_to_group,
|
||||||
"share_subdir_to_group",
|
"share_subdir_to_group",
|
||||||
searpc_signature_int__string_string_string_int_string_string());
|
searpc_signature_string__string_string_string_int_string_string());
|
||||||
|
|
||||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||||
seafile_unshare_subdir_for_group,
|
seafile_unshare_subdir_for_group,
|
||||||
|
Reference in New Issue
Block a user