1
0
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:
cuihaikuo
2016-11-05 11:57:44 +08:00
parent 40c6706acc
commit 46b8d8fda9
5 changed files with 34 additions and 33 deletions

View File

@@ -2437,7 +2437,7 @@ seafile_list_repo_shared_to (const char *from_user, const char *repo_id,
error);
}
int
char *
seafile_share_subdir_to_user (const char *repo_id,
const char *path,
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)) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid repo_id parameter");
return -1;
return NULL;
}
if (is_empty_string (path) || strcmp (path, "/") == 0) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid path parameter");
return -1;
return NULL;
}
if (is_empty_string (owner)) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid owner parameter");
return -1;
return NULL;
}
if (is_empty_string (share_user)) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid share_user parameter");
return -1;
return NULL;
}
if (strcmp (owner, share_user) == 0) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Can't share subdir to myself");
return -1;
return NULL;
}
if (!is_permission_valid (permission)) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid permission parameter");
return -1;
return NULL;
}
char *real_path;
char *vrepo_name;
char *vrepo_id;
int ret = 0;
char *ret = NULL;
real_path = format_dir_path (path);
// 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,
vrepo_name, vrepo_name,
owner, passwd, error);
if (!vrepo_id) {
ret = -1;
if (!vrepo_id)
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);
if (ret < 0) {
if (result < 0) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
"Failed to share subdir to user");
}
g_free (vrepo_id);
}
else
ret = vrepo_id;
out:
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,
const char *path,
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)) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid repo_id parameter");
return -1;
return NULL;
}
if (is_empty_string (path) || strcmp (path, "/") == 0) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid path parameter");
return -1;
return NULL;
}
if (is_empty_string (owner)) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid owner parameter");
return -1;
return NULL;
}
if (share_group < 0) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid share_group parameter");
return -1;
return NULL;
}
if (!is_permission_valid (permission)) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS,
"Invalid permission parameter");
return -1;
return NULL;
}
char *real_path;
char *vrepo_name;
char *vrepo_id;
int ret = 0;
char* ret = NULL;
real_path = format_dir_path (path);
// 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,
vrepo_name, vrepo_name,
owner, passwd, error);
if (!vrepo_id) {
ret = -1;
if (!vrepo_id)
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);
if (ret < 0) {
if (result < 0) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_GENERAL,
"Failed to share subdir to group");
}
g_free (vrepo_id);
}
else
ret = vrepo_id;
out:
g_free (vrepo_name);

View File

@@ -505,7 +505,7 @@ seafile_get_checkout_task (const char *repo_id, GError **error);
GList *
seafile_get_sync_task_list (GError **error);
int
char *
seafile_share_subdir_to_user (const char *repo_id,
const char *path,
const char *owner,
@@ -550,7 +550,7 @@ int
seafile_remove_share (const char *repo_id, const char *from_email,
const char *to_email, GError **error);
int
char *
seafile_share_subdir_to_group (const char *repo_id,
const char *path,
const char *owner,

View File

@@ -52,6 +52,7 @@ func_table = [
[ "string", ["string", "string", "string", "string", "int"] ],
[ "string", ["string", "string", "string", "string", "string"] ],
[ "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", "int"] ],
[ "string", ["string", "string", "string", "string", "string", "string"] ],

View File

@@ -554,7 +554,7 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
pass
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):
pass
@@ -611,7 +611,7 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
pass
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):
pass

View File

@@ -379,7 +379,7 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
searpc_server_register_function ("seafserv-threaded-rpcserver",
seafile_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",
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",
seafile_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",
seafile_unshare_subdir_for_group,