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
This commit is contained in:
VakarisZ 2021-10-18 11:54:06 +03:00
parent b0e96822dd
commit 988bdf0471
2 changed files with 4 additions and 4 deletions

View File

@ -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):

View File

@ -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)