1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 08:53:14 +00:00

Merge branch '6.1'

Conflicts:
	tests/api/test_repo.py
This commit is contained in:
zhengxie
2017-09-19 13:58:36 +08:00
3 changed files with 24 additions and 6 deletions

View File

@@ -11,6 +11,8 @@ from seaserv import seafile_api
from seahub.api2.throttling import UserRateThrottle
from seahub.api2.utils import api_error
from seahub.settings import ENABLE_RESUMABLE_FILEUPLOAD
logger = logging.getLogger(__name__)
json_content_type = 'application/json; charset=utf-8'
@@ -51,4 +53,8 @@ class RepoFileUploadedBytesView(APIView):
error_msg = 'Internal Server Error'
return api_error(status.HTTP_500_INTERNAL_SERVER_ERROR, error_msg)
return Response({"uploadedBytes": uploadedBytes})
response = Response({"uploadedBytes": uploadedBytes})
if ENABLE_RESUMABLE_FILEUPLOAD:
response["Accept-Ranges"] = "bytes"
return response

View File

@@ -321,6 +321,10 @@ class Search(APIView):
if not keyword:
return api_error(status.HTTP_400_BAD_REQUEST, "Missing argument")
with_permission = request.GET.get('with_permission', 'false')
if with_permission and with_permission.lower() not in ('true', 'false'):
return api_error(status.HTTP_400_BAD_REQUEST, "with_permission invalid.")
search_repo = request.GET.get('search_repo', None) # val: 'all' or 'search_repo_id'
if search_repo and search_repo != 'all':
@@ -335,20 +339,27 @@ class Search(APIView):
error_msg = 'Library %s not found.' % search_repo
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
username = request.user.username
results, total, has_more = search_keyword(request, keyword)
for e in results:
e.pop('repo', None)
e.pop('exists', None)
e.pop('last_modified_by', None)
e.pop('name_highlight', None)
e.pop('score', None)
repo_id = e['repo_id']
path = e['fullpath']
try:
path = e['fullpath']
file_id = seafile_api.get_file_id_by_path(e['repo_id'], path)
e['oid'] = file_id
repo = get_repo(e['repo_id'])
repo = get_repo(repo_id)
e['repo_name'] = repo.name
e['size'] = get_file_size(repo.store_id, repo.version, file_id)
dirent = seafile_api.get_dirent_by_path(repo.store_id, path)
e['size'] = dirent.size
if with_permission.lower() == 'true':
e['permission'] = seafile_api.check_permission_by_path(repo_id, path, username)
except SearpcError as e:
logger.error(e)
pass

View File

@@ -190,6 +190,7 @@ class RepoTest(BaseTestCase):
def test_can_get_share_group_repo(self):
config.ENABLE_SHARE_TO_ALL_GROUPS = True
self.logout()
self.login_as(self.admin)
share_repo = seafile_api.get_repo(self.create_repo(