From 72fae2d110ad625e77284ef5f3a892805b56713a Mon Sep 17 00:00:00 2001 From: Leo Date: Mon, 23 Sep 2019 14:24:47 +0800 Subject: [PATCH] still remove repo when data is damaged in seafile-date (#4105) --- seahub/api2/endpoints/repos.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/seahub/api2/endpoints/repos.py b/seahub/api2/endpoints/repos.py index aaf2c81613..a80a49fe35 100644 --- a/seahub/api2/endpoints/repos.py +++ b/seahub/api2/endpoints/repos.py @@ -351,8 +351,17 @@ class RepoView(APIView): repo = seafile_api.get_repo(repo_id) if not repo: - error_msg = 'Library %s not found.' % repo_id - return api_error(status.HTTP_404_NOT_FOUND, error_msg) + # for case of `seafile-data` has been damaged + # no `repo object` will be returned from seafile api + # delete the database record anyway + try: + seafile_api.remove_repo(repo_id) + except Exception as e: + logger.error(e) + error_msg = 'Internal Server Error' + return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg) + + return Response({'success': True}) # check permission username = request.user.username