diff --git a/apps/audits/api.py b/apps/audits/api.py index e88afe7ed..56fff6297 100644 --- a/apps/audits/api.py +++ b/apps/audits/api.py @@ -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) diff --git a/apps/audits/tasks.py b/apps/audits/tasks.py index a0da3f782..ffda01219 100644 --- a/apps/audits/tasks.py +++ b/apps/audits/tasks.py @@ -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 diff --git a/apps/terminal/api/session/session.py b/apps/terminal/api/session/session.py index 9fdd855c8..c414dd289 100644 --- a/apps/terminal/api/session/session.py +++ b/apps/terminal/api/session/session.py @@ -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) diff --git a/apps/terminal/tasks.py b/apps/terminal/tasks.py index e6f8a9140..380bd94f6 100644 --- a/apps/terminal/tasks.py +++ b/apps/terminal/tasks.py @@ -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