Skip to content

Commit

Permalink
Merge pull request #1480 from haiwen/ret-corrupted
Browse files Browse the repository at this point in the history
[rpc] add ret_corrupted parameter for list_owned_repos rpc
  • Loading branch information
killing committed Dec 16, 2015
2 parents ae2f05e + 8fb8f28 commit a7c9abe
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions common/rpc-service.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion include/seafile-rpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions python/seafile/rpcclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions python/seaserv/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions server/repo-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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=?";

Expand All @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion server/repo-mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion server/seaf-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a7c9abe

Please sign in to comment.