From e4823a21e38102a2dc48fc19cdb77cd98cd07a03 Mon Sep 17 00:00:00 2001 From: ibuler <ibuler@qq.com> Date: Mon, 12 Mar 2018 18:29:06 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/api.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/terminal/api.py b/apps/terminal/api.py index 745079869..8247ac27c 100644 --- a/apps/terminal/api.py +++ b/apps/terminal/api.py @@ -284,15 +284,18 @@ class SessionReplayViewSet(viewsets.ViewSet): return redirect(url) else: configs = settings.TERMINAL_REPLAY_STORAGE.items() - if configs: - for name, config in configs: - client = jms_storage.init(config) - date = self.session.date_start.strftime('%Y-%m-%d') - if client and client.has_file(os.path.join(date, str(self.session.id) + '.replay.gz')) \ - and \ - client.download_file(os.path.join(date, str(self.session.id) + '.replay.gz'), - default_storage.base_location + '/' + path): - return redirect(default_storage.url(path)) + if not configs: + return HttpResponseNotFound() + + for name, config in configs: + client = jms_storage.init(config) + date = self.session.date_start.strftime('%Y-%m-%d') + file_path = os.path.join(date, str(self.session.id) + '.replay.gz') + target_path = default_storage.base_location + '/' + path + + if client and client.has_file(file_path) and \ + client.download_file(file_path, target_path): + return redirect(default_storage.url(path)) return HttpResponseNotFound()