mirror of https://github.com/jumpserver/jumpserver
perf: 优化变量名
parent
9a29cda210
commit
a991a6c56c
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue