Commit e4823a21 authored by ibuler's avatar ibuler

[Update] 优化部分代码

parent 634af199
...@@ -284,15 +284,18 @@ class SessionReplayViewSet(viewsets.ViewSet): ...@@ -284,15 +284,18 @@ class SessionReplayViewSet(viewsets.ViewSet):
return redirect(url) return redirect(url)
else: else:
configs = settings.TERMINAL_REPLAY_STORAGE.items() configs = settings.TERMINAL_REPLAY_STORAGE.items()
if configs: if not configs:
for name, config in configs: return HttpResponseNotFound()
client = jms_storage.init(config)
date = self.session.date_start.strftime('%Y-%m-%d') for name, config in configs:
if client and client.has_file(os.path.join(date, str(self.session.id) + '.replay.gz')) \ client = jms_storage.init(config)
and \ date = self.session.date_start.strftime('%Y-%m-%d')
client.download_file(os.path.join(date, str(self.session.id) + '.replay.gz'), file_path = os.path.join(date, str(self.session.id) + '.replay.gz')
default_storage.base_location + '/' + path): target_path = default_storage.base_location + '/' + path
return redirect(default_storage.url(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() return HttpResponseNotFound()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment