1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-08-23 17:18:27 +00:00

[RPC] Add 'delta' parameter to check_quota RPC.

This commit is contained in:
Jiaqiang Xu 2016-09-21 10:57:29 +08:00
parent aafc3af1d4
commit 29b82e62d6
7 changed files with 17 additions and 11 deletions

View File

@ -4056,14 +4056,19 @@ seafile_get_user_quota (const char *user, GError **error)
} }
int int
seafile_check_quota (const char *repo_id, GError **error) seafile_check_quota (const char *repo_id, gint64 delta, GError **error)
{ {
int rc;
if (!repo_id) { if (!repo_id) {
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Bad arguments"); g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Bad arguments");
return -1; return -1;
} }
return seaf_quota_manager_check_quota (seaf->quota_mgr, repo_id); rc = seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, repo_id, delta);
if (rc == 1)
return -1;
return rc;
} }
static char * static char *

View File

@ -802,7 +802,7 @@ gint64
seafile_get_user_quota (const char *user, GError **error); seafile_get_user_quota (const char *user, GError **error);
int int
seafile_check_quota (const char *repo_id, GError **error); seafile_check_quota (const char *repo_id, gint64 delta, GError **error);
char * char *
seafile_get_file_id_by_path (const char *repo_id, const char *path, seafile_get_file_id_by_path (const char *repo_id, const char *path,

View File

@ -391,10 +391,11 @@ seafile_set_org_user_quota (SearpcClient *client,
int int
seafile_check_quota (SearpcClient *client, seafile_check_quota (SearpcClient *client,
const char *repo_id, const char *repo_id,
gint64 delta,
GError **error) GError **error)
{ {
return searpc_client_call__int (client, "check_quota", error, return searpc_client_call__int (client, "check_quota", error,
1, "string", repo_id); 2, "string", repo_id, "int64", delta);
} }
int int

View File

@ -753,8 +753,8 @@ class SeafServerThreadedRpcClient(ccnet.RpcClientBase):
def get_org_user_quota(org_id, user): def get_org_user_quota(org_id, user):
pass pass
@searpc_func("int", ["string"]) @searpc_func("int", ["string", "int64"])
def check_quota(repo_id): def check_quota(repo_id, delta):
pass pass
# password management # password management

View File

@ -575,8 +575,8 @@ class SeafileAPI(object):
def set_user_share_quota(self, username, quota): def set_user_share_quota(self, username, quota):
pass pass
def check_quota(self, repo_id): def check_quota(self, repo_id, delta=0):
pass return seafserv_threaded_rpc.check_quota(repo_id, delta)
# encrypted repo password management # encrypted repo password management
def check_passwd(self, repo_id, magic): def check_passwd(self, repo_id, magic):

View File

@ -881,9 +881,9 @@ def get_related_users_by_org_repo(org_id, repo_id):
return users return users
# quota # quota
def check_quota(repo_id): def check_quota(repo_id, delta=0):
try: try:
ret = seafserv_threaded_rpc.check_quota(repo_id) ret = seafserv_threaded_rpc.check_quota(repo_id, delta)
except SearpcError, e: except SearpcError, e:
logger.error(e) logger.error(e)
ret = -1 ret = -1

View File

@ -610,7 +610,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_check_quota, seafile_check_quota,
"check_quota", "check_quota",
searpc_signature_int__string()); searpc_signature_int__string_int64());
/* repo permission */ /* repo permission */
searpc_server_register_function ("seafserv-threaded-rpcserver", searpc_server_register_function ("seafserv-threaded-rpcserver",