From 8fb8f2805d54cf17376776646e96ee731d09c577 Mon Sep 17 00:00:00 2001 From: yejianguo Date: Wed, 16 Dec 2015 12:01:16 +0800 Subject: [PATCH] [rpc] add ret_corrupted parameter for list_owned_repos rpc --- common/rpc-service.c | 4 ++-- include/seafile-rpc.h | 2 +- python/seafile/rpcclient.py | 4 ++-- python/seaserv/api.py | 5 +++-- server/repo-mgr.c | 10 ++++++++-- server/repo-mgr.h | 3 ++- server/seaf-server.c | 2 +- 7 files changed, 19 insertions(+), 11 deletions(-) diff --git a/common/rpc-service.c b/common/rpc-service.c index 18851afb3..72925142d 100644 --- a/common/rpc-service.c +++ b/common/rpc-service.c @@ -2040,14 +2040,14 @@ seafile_get_orphan_repo_list(GError **error) } GList * -seafile_list_owned_repos (const char *email, GError **error) +seafile_list_owned_repos (const char *email, int ret_corrupted, GError **error) { GList *ret = NULL; GList *repos, *ptr; char *repo_id = NULL; int is_shared; - repos = seaf_repo_manager_get_repos_by_owner (seaf->repo_mgr, email); + repos = seaf_repo_manager_get_repos_by_owner (seaf->repo_mgr, email, ret_corrupted); ret = convert_repo_list (repos); for (ptr = ret; ptr; ptr = ptr->next) { diff --git a/include/seafile-rpc.h b/include/seafile-rpc.h index 8d3124376..a8fc303f4 100644 --- a/include/seafile-rpc.h +++ b/include/seafile-rpc.h @@ -433,7 +433,7 @@ GList * seafile_get_orphan_repo_list(GError **error); GList * -seafile_list_owned_repos (const char *email, GError **error); +seafile_list_owned_repos (const char *email, int ret_corrupted, GError **error); /** * seafile_add_chunk_server: diff --git a/python/seafile/rpcclient.py b/python/seafile/rpcclient.py index d09094367..5f1e3586f 100644 --- a/python/seafile/rpcclient.py +++ b/python/seafile/rpcclient.py @@ -370,8 +370,8 @@ def seafile_get_orphan_repo_list(): pass get_orphan_repo_list = seafile_get_orphan_repo_list - @searpc_func("objlist", ["string"]) - def seafile_list_owned_repos(user_id): + @searpc_func("objlist", ["string", "int"]) + def seafile_list_owned_repos(user_id, ret_corrupted): pass list_owned_repos = seafile_list_owned_repos diff --git a/python/seaserv/api.py b/python/seaserv/api.py index a193a4d77..4c31cb86c 100644 --- a/python/seaserv/api.py +++ b/python/seaserv/api.py @@ -76,8 +76,9 @@ def set_repo_owner(self, email, repo_id): def get_repo_owner(self, repo_id): return seafserv_threaded_rpc.get_repo_owner(repo_id) - def get_owned_repo_list(self, username): - return seafserv_threaded_rpc.list_owned_repos(username) + def get_owned_repo_list(self, username, ret_corrupted=False): + return seafserv_threaded_rpc.list_owned_repos(username, + 1 if ret_corrupted else 0) def get_orphan_repo_list(self): return seafserv_threaded_rpc.get_orphan_repo_list() diff --git a/server/repo-mgr.c b/server/repo-mgr.c index 714e79143..21ad08865 100644 --- a/server/repo-mgr.c +++ b/server/repo-mgr.c @@ -2028,11 +2028,13 @@ seaf_repo_manager_get_orphan_repo_list (SeafRepoManager *mgr) GList * seaf_repo_manager_get_repos_by_owner (SeafRepoManager *mgr, - const char *email) + const char *email, + int ret_corrupted) { GList *id_list = NULL, *ptr; GList *ret = NULL; char *sql; + SeafRepo *repo = NULL; sql = "SELECT repo_id FROM RepoOwner WHERE owner_id=?"; @@ -2043,7 +2045,11 @@ seaf_repo_manager_get_repos_by_owner (SeafRepoManager *mgr, for (ptr = id_list; ptr; ptr = ptr->next) { char *repo_id = ptr->data; - SeafRepo *repo = seaf_repo_manager_get_repo (mgr, repo_id); + if (ret_corrupted) { + repo = seaf_repo_manager_get_repo_ex (mgr, repo_id); + } else { + repo = seaf_repo_manager_get_repo (mgr, repo_id); + } if (repo != NULL) ret = g_list_prepend (ret, repo); } diff --git a/server/repo-mgr.h b/server/repo-mgr.h index 34e6de98d..fe6d3a458 100644 --- a/server/repo-mgr.h +++ b/server/repo-mgr.h @@ -538,7 +538,8 @@ seaf_repo_manager_get_orphan_repo_list (SeafRepoManager *mgr); */ GList * seaf_repo_manager_get_repos_by_owner (SeafRepoManager *mgr, - const char *email); + const char *email, + int ret_corrupted); GList * seaf_repo_manager_get_repo_ids_by_owner (SeafRepoManager *mgr, diff --git a/server/seaf-server.c b/server/seaf-server.c index b21b23170..f9f256df1 100644 --- a/server/seaf-server.c +++ b/server/seaf-server.c @@ -177,7 +177,7 @@ static void start_rpc_service (CcnetClient *client, int cloud_mode) searpc_server_register_function ("seafserv-threaded-rpcserver", seafile_list_owned_repos, "seafile_list_owned_repos", - searpc_signature_objlist__string()); + searpc_signature_objlist__string_int()); searpc_server_register_function ("seafserv-threaded-rpcserver", seafile_server_repo_size,