1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-22 00:43:28 +00:00

fix fix file_download_link (#5626)

This commit is contained in:
欢乐马 2023-09-06 11:28:56 +08:00 committed by GitHub
parent ae90c40dde
commit 3b246f7aa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 13 deletions

View File

@ -246,7 +246,7 @@ class SeadocRevisionDownloadLinks(APIView):
return api_error(status.HTTP_400_BAD_REQUEST, error_msg)
file_download_link = get_seadoc_download_link(uuid_map, False)
file_download_link = get_seadoc_download_link(uuid_map)
if not file_download_link:
error_msg = 'seadoc file %s not found.' % uuid_map.filename
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
@ -264,7 +264,7 @@ class SeadocRevisionDownloadLinks(APIView):
error_msg = 'seadoc origin uuid %s not found.' % origin_doc_uuid
return api_error(status.HTTP_404_NOT_FOUND, error_msg)
origin_file_download_link = get_seadoc_download_link(origin_uuid_map, False)
origin_file_download_link = get_seadoc_download_link(origin_uuid_map)
if not origin_file_download_link:
error_msg = 'seadoc origin file %s not found.' % origin_uuid_map.filename
return api_error(status.HTTP_404_NOT_FOUND, error_msg)

View File

@ -10,8 +10,7 @@ from seaserv import seafile_api
from seahub.tags.models import FileUUIDMap
from seahub.settings import SEADOC_PRIVATE_KEY
from seahub.utils import normalize_file_path, gen_inner_file_get_url, gen_inner_file_upload_url, \
gen_file_get_url, gen_file_upload_url
from seahub.utils import normalize_file_path, gen_file_get_url, gen_file_upload_url
from seahub.views import check_folder_permission
from seahub.base.templatetags.seahub_tags import email2nickname
from seahub.avatar.templatetags.avatar_tags import api_avatar_url
@ -110,11 +109,11 @@ def get_seadoc_upload_link(uuid_map, last_modify_user=''):
repo_id, obj_id, 'update', last_modify_user, use_onetime=True)
if not token:
return None
upload_link = gen_inner_file_upload_url('update-api', token)
upload_link = gen_file_upload_url('update-api', token)
return upload_link
def get_seadoc_download_link(uuid_map, is_inner=True):
def get_seadoc_download_link(uuid_map):
repo_id = uuid_map.repo_id
parent_path = uuid_map.parent_path
filename = uuid_map.filename
@ -127,9 +126,6 @@ def get_seadoc_download_link(uuid_map, is_inner=True):
repo_id, obj_id, 'view', '', use_onetime=False)
if not token:
return None
if is_inner:
download_link = gen_inner_file_get_url(token, filename)
return download_link
download_link = gen_file_get_url(token, filename)
return download_link
@ -149,7 +145,7 @@ def get_seadoc_asset_upload_link(repo_id, parent_path, username):
repo_id, obj_id, 'upload-link', username, use_onetime=True)
if not token:
return None
upload_link = gen_inner_file_upload_url('upload-api', token)
upload_link = gen_file_upload_url('upload-api', token)
upload_link = upload_link + '?replace=1'
return upload_link
@ -163,7 +159,7 @@ def get_seadoc_asset_download_link(repo_id, parent_path, filename, username):
repo_id, obj_id, 'view', username, use_onetime=False)
if not token:
return None
download_link = gen_inner_file_get_url(token, filename)
download_link = gen_file_get_url(token, filename)
return download_link

View File

@ -53,7 +53,7 @@ def sdoc_revision(request, repo_id):
'is_owner': is_owner,
'can_compare': True,
'assets_url': '/api/v2.1/seadoc/download-image/' + file_uuid,
'file_download_link': get_seadoc_download_link(uuid_map, False)
'file_download_link': get_seadoc_download_link(uuid_map)
}
revision_info = is_seadoc_revision(file_uuid)
@ -63,7 +63,7 @@ def sdoc_revision(request, repo_id):
is_published = return_dict.get('is_published', False)
if (origin_doc_uuid and not is_published):
uuid_map = FileUUIDMap.objects.get_fileuuidmap_by_uuid(origin_doc_uuid)
return_dict['origin_file_download_link'] = get_seadoc_download_link(uuid_map, False)
return_dict['origin_file_download_link'] = get_seadoc_download_link(uuid_map)
return render(request, 'sdoc_revision.html', return_dict)