From 4f289963d19d6339ef7a37101fad0135e0fcdeb1 Mon Sep 17 00:00:00 2001 From: BaiJiangJie <32935519+BaiJiangJie@users.noreply.github.com> Date: Mon, 3 Jun 2019 14:47:33 +0800 Subject: [PATCH] =?UTF-8?q?[Update]=20=E4=BF=AE=E6=94=B9=E5=BD=95=E5=83=8F?= =?UTF-8?q?=E5=9B=9E=E6=94=BE=E5=88=A4=E6=96=AD=E9=80=BB=E8=BE=91=20(#2768?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/terminal/models.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/apps/terminal/models.py b/apps/terminal/models.py index 0e17b1d9a..0bcceef58 100644 --- a/apps/terminal/models.py +++ b/apps/terminal/models.py @@ -167,6 +167,7 @@ class Session(OrgModelMixin): upload_to = 'replay' ACTIVE_CACHE_KEY_PREFIX = 'SESSION_ACTIVE_{}' + _DATE_START_FIRST_HAS_REPLAY_RDP_SESSION = None def get_rel_replay_path(self, version=2): """ @@ -188,13 +189,29 @@ class Session(OrgModelMixin): local_path = rel_path return local_path + @property + def _date_start_first_has_replay_rdp_session(self): + if self._DATE_START_FIRST_HAS_REPLAY_RDP_SESSION is None: + instance = self.__class__.objects.filter( + protocol='rdp', has_replay=True).order_by('date_start').first() + if not instance: + return None + self._DATE_START_FIRST_HAS_REPLAY_RDP_SESSION = instance.date_start + + return self._DATE_START_FIRST_HAS_REPLAY_RDP_SESSION + def can_replay(self): if self.has_replay: return True - version = settings.VERSION.split('.') - if [int(i) for i in version] > [1, 4, 8]: - return False - return True + + # 判断对RDP Session添加上报has_replay状态机制之前的录像回放 + if self._date_start_first_has_replay_rdp_session is None: + return True + + if self.date_start < self._date_start_first_has_replay_rdp_session: + return True + + return False def save_to_storage(self, f): local_path = self.get_local_path()