From 988bdf047117657cad5066387c0963ab6f05d632 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Mon, 18 Oct 2021 11:54:06 +0300 Subject: [PATCH] Island: check if version from version file is the same as in island instead of checking if it's lower This change enables to clean the directory if an older version of monkey island is installed after removing the new one --- monkey/monkey_island/cc/setup/data_dir.py | 4 ++-- monkey/monkey_island/cc/setup/version_file_setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/monkey/monkey_island/cc/setup/data_dir.py b/monkey/monkey_island/cc/setup/data_dir.py index 0ba011d65..5ea3b49e9 100644 --- a/monkey/monkey_island/cc/setup/data_dir.py +++ b/monkey/monkey_island/cc/setup/data_dir.py @@ -6,7 +6,7 @@ from common.version import get_version from monkey_island.cc.server_utils.file_utils import create_secure_directory from monkey_island.cc.setup.version_file_setup import ( get_version_from_dir, - is_version_greater, + is_version_different, write_version, ) @@ -40,7 +40,7 @@ def _is_backup_needed(data_dir_path: Path) -> bool: island_version = get_version() - return is_version_greater(island_version, data_dir_version) + return is_version_different(island_version, data_dir_version) def _rename_data_dir(data_dir_path: Path): diff --git a/monkey/monkey_island/cc/setup/version_file_setup.py b/monkey/monkey_island/cc/setup/version_file_setup.py index 52a71ce4f..a1fb2a801 100644 --- a/monkey/monkey_island/cc/setup/version_file_setup.py +++ b/monkey/monkey_island/cc/setup/version_file_setup.py @@ -17,5 +17,5 @@ def write_version(dir_path: Path): version_file_path.write_text(get_version()) -def is_version_greater(version1: str, version2: str) -> bool: - return version.parse(version1) > version.parse(version2) +def is_version_different(version1: str, version2: str) -> bool: + return not version.parse(version1) == version.parse(version2)