From 3e00631925ad86740319e7db9eddd9c784aa8613 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Mon, 7 Dec 2020 09:50:15 +0000 Subject: [PATCH] cleanup older pending action agent updates if one exists with an older agent version --- api/tacticalrmm/agents/tasks.py | 20 ++++++++++++++++++-- api/tacticalrmm/tacticalrmm/settings.py | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/api/tacticalrmm/agents/tasks.py b/api/tacticalrmm/agents/tasks.py index e846c42825..ffe7fd6290 100644 --- a/api/tacticalrmm/agents/tasks.py +++ b/api/tacticalrmm/agents/tasks.py @@ -54,7 +54,15 @@ def send_agent_update_task(pks, version): if agent.pendingactions.filter( action_type="agentupdate", status="pending" ).exists(): - continue + action = agent.pendingactions.filter( + action_type="agentupdate", status="pending" + ).last() + if pyver.parse(action.details["version"]) < pyver.parse( + settings.LATEST_AGENT_VER + ): + action.delete() + else: + continue PendingAction.objects.create( agent=agent, @@ -122,7 +130,15 @@ def auto_self_agent_update_task(): if agent.pendingactions.filter( action_type="agentupdate", status="pending" ).exists(): - continue + action = agent.pendingactions.filter( + action_type="agentupdate", status="pending" + ).last() + if pyver.parse(action.details["version"]) < pyver.parse( + settings.LATEST_AGENT_VER + ): + action.delete() + else: + continue PendingAction.objects.create( agent=agent, diff --git a/api/tacticalrmm/tacticalrmm/settings.py b/api/tacticalrmm/tacticalrmm/settings.py index 0759983b29..6be4a7841a 100644 --- a/api/tacticalrmm/tacticalrmm/settings.py +++ b/api/tacticalrmm/tacticalrmm/settings.py @@ -15,7 +15,7 @@ AUTH_USER_MODEL = "accounts.User" # latest release -TRMM_VERSION = "0.2.6" +TRMM_VERSION = "0.2.7" # bump this version everytime vue code is changed # to alert user they need to manually refresh their browser