forked from p15670423/monkey
Monkey: simplify version comparison to string comparison instead of using a package to parse the version
This commit is contained in:
parent
c23a0721c5
commit
27d04e4de6
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue