From 27d04e4de662053076b509e6f92e462e9a03f005 Mon Sep 17 00:00:00 2001 From: VakarisZ Date: Tue, 19 Oct 2021 10:45:44 +0300 Subject: [PATCH] Monkey: simplify version comparison to string comparison instead of using a package to parse the version --- monkey/monkey_island/cc/setup/data_dir.py | 8 ++------ monkey/monkey_island/cc/setup/version_file_setup.py | 6 ------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/monkey/monkey_island/cc/setup/data_dir.py b/monkey/monkey_island/cc/setup/data_dir.py index 5ea3b49e9..590e966ba 100644 --- a/monkey/monkey_island/cc/setup/data_dir.py +++ b/monkey/monkey_island/cc/setup/data_dir.py @@ -4,11 +4,7 @@ from pathlib import Path 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_different, - write_version, -) +from monkey_island.cc.setup.version_file_setup import get_version_from_dir, write_version logger = logging.getLogger(__name__) _data_dir_backup_suffix = ".old" @@ -40,7 +36,7 @@ def _is_backup_needed(data_dir_path: Path) -> bool: island_version = get_version() - return is_version_different(island_version, data_dir_version) + return 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 a1fb2a801..380fcf4cc 100644 --- a/monkey/monkey_island/cc/setup/version_file_setup.py +++ b/monkey/monkey_island/cc/setup/version_file_setup.py @@ -1,7 +1,5 @@ from pathlib import Path -from packaging import version - from common.version import get_version _version_filename = "VERSION" @@ -15,7 +13,3 @@ def get_version_from_dir(dir_path: Path) -> str: def write_version(dir_path: Path): version_file_path = dir_path.joinpath(_version_filename) version_file_path.write_text(get_version()) - - -def is_version_different(version1: str, version2: str) -> bool: - return not version.parse(version1) == version.parse(version2)