perf: 优化变量名

pull/10691/head
jiangweidong 2023-06-13 11:33:08 +08:00 committed by Jiangjie.Bai
parent 9a29cda210
commit a991a6c56c
4 changed files with 12 additions and 9 deletions

View File

@ -79,9 +79,10 @@ class FTPLogViewSet(OrgModelViewSet):
def download(self, request, *args, **kwargs):
ftp_log = self.get_object()
ftp_storage = self.get_storage()
local_path, url_or_err = ftp_storage.get_file_path_url()
local_path, url = ftp_storage.get_file_path_url()
if local_path is None:
return HttpResponse(url_or_err)
# url => error message
return HttpResponse(url)
file = open(default_storage.path(local_path), 'rb')
response = FileResponse(file)

View File

@ -119,7 +119,7 @@ def upload_ftp_file_to_external_storage(ftp_log_id, file_name):
logger.error(f'FTP db item not found: {ftp_log_id}')
return
ftp_storage = FTPFileStorageHandler(ftp_log)
local_path, url_or_err = ftp_storage.find_local()
local_path, url = ftp_storage.find_local()
if not local_path:
logger.error(f'FTP file record not found, may be upload error. file name: {file_name}')
return

View File

@ -117,9 +117,10 @@ class SessionViewSet(OrgBulkModelViewSet):
url_name='replay-download')
def download(self, request, *args, **kwargs):
storage = self.get_storage()
local_path, url_or_err = storage.get_file_path_url()
local_path, url = storage.get_file_path_url()
if local_path is None:
return Response({'error': url_or_err}, status=404)
# url => error message
return Response({'error': url}, status=404)
file = self.prepare_offline_file(storage.obj, local_path)
response = FileResponse(file)
@ -211,10 +212,11 @@ class SessionReplayViewSet(AsyncApiMixin, viewsets.ViewSet):
session = get_object_or_404(Session, id=session_id)
storage = ReplayStorageHandler(session)
local_path, url_or_err = storage.get_file_path_url()
local_path, url = storage.get_file_path_url()
if local_path is None:
return Response({"error": url_or_err}, status=404)
data = self.get_replay_data(session, url_or_err)
# url => error message
return Response({"error": url}, status=404)
data = self.get_replay_data(session, url)
return Response(data)

View File

@ -67,7 +67,7 @@ def upload_session_replay_to_external_storage(session_id):
return
replay_storage = ReplayStorageHandler(session)
local_path, url_or_err = replay_storage.find_local()
local_path, url = replay_storage.find_local()
if not local_path:
logger.error(f'Session replay not found, may be upload error: {local_path}')
return