Skip to content

Commit 29b82e6

Browse files
committed
[RPC] Add 'delta' parameter to check_quota RPC.
1 parent aafc3af commit 29b82e6

File tree

7 files changed

+17
-11
lines changed

7 files changed

+17
-11
lines changed

common/rpc-service.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,14 +4056,19 @@ seafile_get_user_quota (const char *user, GError **error)
40564056
}
40574057

40584058
int
4059-
seafile_check_quota (const char *repo_id, GError **error)
4059+
seafile_check_quota (const char *repo_id, gint64 delta, GError **error)
40604060
{
4061+
int rc;
4062+
40614063
if (!repo_id) {
40624064
g_set_error (error, SEAFILE_DOMAIN, SEAF_ERR_BAD_ARGS, "Bad arguments");
40634065
return -1;
40644066
}
40654067

4066-
return seaf_quota_manager_check_quota (seaf->quota_mgr, repo_id);
4068+
rc = seaf_quota_manager_check_quota_with_delta (seaf->quota_mgr, repo_id, delta);
4069+
if (rc == 1)
4070+
return -1;
4071+
return rc;
40674072
}
40684073

40694074
static char *

include/seafile-rpc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ gint64
802802
seafile_get_user_quota (const char *user, GError **error);
803803

804804
int
805-
seafile_check_quota (const char *repo_id, GError **error);
805+
seafile_check_quota (const char *repo_id, gint64 delta, GError **error);
806806

807807
char *
808808
seafile_get_file_id_by_path (const char *repo_id, const char *path,

lib/seafile-rpc-wrapper.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,11 @@ seafile_set_org_user_quota (SearpcClient *client,
391391
int
392392
seafile_check_quota (SearpcClient *client,
393393
const char *repo_id,
394+
gint64 delta,
394395
GError **error)
395396
{
396397
return searpc_client_call__int (client, "check_quota", error,
397-
1, "string", repo_id);
398+
2, "string", repo_id, "int64", delta);
398399
}
399400

400401
int

python/seafile/rpcclient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -753,8 +753,8 @@ def set_org_user_quota(org_id, user, quota):
753753
def get_org_user_quota(org_id, user):
754754
pass
755755

756-
@searpc_func("int", ["string"])
757-
def check_quota(repo_id):
756+
@searpc_func("int", ["string", "int64"])
757+
def check_quota(repo_id, delta):
758758
pass
759759

760760
# password management

python/seaserv/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,8 +575,8 @@ def get_user_share_quota(self, username):
575575
def set_user_share_quota(self, username, quota):
576576
pass
577577

578-
def check_quota(self, repo_id):
579-
pass
578+
def check_quota(self, repo_id, delta=0):
579+
return seafserv_threaded_rpc.check_quota(repo_id, delta)
580580

581581
# encrypted repo password management
582582
def check_passwd(self, repo_id, magic):

python/seaserv/service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,9 +881,9 @@ def get_related_users_by_org_repo(org_id, repo_id):
881881
return users
882882

883883
# quota
884-
def check_quota(repo_id):
884+
def check_quota(repo_id, delta=0):
885885
try:
886-
ret = seafserv_threaded_rpc.check_quota(repo_id)
886+
ret = seafserv_threaded_rpc.check_quota(repo_id, delta)
887887
except SearpcError, e:
888888
logger.error(e)
889889
ret = -1

server/seaf-server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode)
610610
searpc_server_register_function ("seafserv-threaded-rpcserver",
611611
seafile_check_quota,
612612
"check_quota",
613-
searpc_signature_int__string());
613+
searpc_signature_int__string_int64());
614614

615615
/* repo permission */
616616
searpc_server_register_function ("seafserv-threaded-rpcserver",

0 commit comments

Comments
 (0)