mirror of
https://github.com/haiwen/seafile-server.git
synced 2025-09-01 15:36:37 +00:00
Add rpc repo_has_been_shared().
This commit is contained in:
@@ -5243,4 +5243,17 @@ seafile_get_org_group_repos_by_user (const char *user, int org_id, GError **erro
|
||||
|
||||
return seaf_get_group_repos_by_user (mgr, user, org_id, error);
|
||||
}
|
||||
|
||||
int
|
||||
seafile_repo_has_been_shared (const char *repo_id, int including_groups, GError **error)
|
||||
{
|
||||
if (!repo_id) {
|
||||
g_set_error (error, 0, SEAF_ERR_BAD_ARGS, "Arguments error");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean exists = seaf_share_manager_repo_has_been_shared (seaf->share_mgr, repo_id,
|
||||
including_groups ? TRUE : FALSE);
|
||||
return exists ? 1 : 0;
|
||||
}
|
||||
#endif /* SEAFILE_SERVER */
|
||||
|
@@ -1091,4 +1091,7 @@ seafile_get_group_repos_by_user (const char *user, GError **error);
|
||||
|
||||
GList *
|
||||
seafile_get_org_group_repos_by_user (const char *user, int org_id, GError **error);
|
||||
|
||||
int
|
||||
seafile_repo_has_been_shared (const char *repo_id, int including_groups, GError **error);
|
||||
#endif
|
||||
|
@@ -1025,3 +1025,7 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
|
||||
@searpc_func("int", ["string", "string", "int"])
|
||||
def set_server_config_boolean (group, key, value):
|
||||
pass
|
||||
|
||||
@searpc_func("int", ["string", "int"])
|
||||
def repo_has_been_shared (repo_id, including_groups):
|
||||
pass
|
||||
|
@@ -737,6 +737,9 @@ class SeafileAPI(object):
|
||||
def del_org_group_repo(self, repo_id, org_id, group_id):
|
||||
seafserv_threaded_rpc.del_org_group_repo(repo_id, org_id, group_id)
|
||||
|
||||
def repo_has_been_shared(self, repo_id, including_groups=False):
|
||||
return True if seafserv_threaded_rpc.repo_has_been_shared(repo_id, 1 if including_groups else 0) else False
|
||||
|
||||
seafile_api = SeafileAPI()
|
||||
|
||||
class CcnetAPI(object):
|
||||
|
@@ -502,6 +502,11 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
|
||||
"seafile_get_shared_groups_for_subdir",
|
||||
searpc_signature_objlist__string_string_string());
|
||||
|
||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||
seafile_repo_has_been_shared,
|
||||
"repo_has_been_shared",
|
||||
searpc_signature_int__string_int());
|
||||
|
||||
/* branch and commit */
|
||||
searpc_server_register_function ("seafserv-threaded-rpcserver",
|
||||
seafile_branch_gets,
|
||||
|
@@ -758,3 +758,29 @@ seaf_share_manager_unshare_group_subdir (SeafShareManager* mgr,
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean
|
||||
seaf_share_manager_repo_has_been_shared (SeafShareManager* mgr,
|
||||
const char *repo_id,
|
||||
gboolean including_groups)
|
||||
{
|
||||
gboolean exists;
|
||||
gboolean db_err = FALSE;
|
||||
char *sql;
|
||||
|
||||
sql = "SELECT 1 FROM SharedRepo WHERE repo_id=?";
|
||||
exists = seaf_db_statement_exists (mgr->seaf->db, sql, &db_err,
|
||||
1, "string", repo_id);
|
||||
if (db_err) {
|
||||
seaf_warning ("DB error when check repo exist in SharedRepo and RepoGroup.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!exists && including_groups) {
|
||||
sql = "SELECT 1 FROM RepoGroup WHERE repo_id=?";
|
||||
exists = seaf_db_statement_exists (mgr->seaf->db, sql, &db_err,
|
||||
1, "string", repo_id);
|
||||
}
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
@@ -102,5 +102,9 @@ seaf_share_manager_unshare_group_subdir (SeafShareManager* mgr,
|
||||
const char *owner,
|
||||
int group_id);
|
||||
|
||||
gboolean
|
||||
seaf_share_manager_repo_has_been_shared (SeafShareManager* mgr,
|
||||
const char *repo_id,
|
||||
gboolean including_groups);
|
||||
#endif /* SHARE_MGR_H */
|
||||
|
||||
|
Reference in New Issue
Block a user