diff --git a/pleskdistup/common/src/mounts.py b/pleskdistup/common/src/mounts.py index d00fb78..d39b504 100644 --- a/pleskdistup/common/src/mounts.py +++ b/pleskdistup/common/src/mounts.py @@ -22,7 +22,7 @@ def get_fstab_configuration_misorderings(configpath: str) -> typing.List[typing. if not os.path.exists(configpath): return [] - mount_points_order = {} + mount_points_order: typing.Dict[str, int] = {} with open(configpath, "r") as f: for iter, line in enumerate(f.readlines()): if line.startswith("#") or line == "\n" or line == "": @@ -30,18 +30,19 @@ def get_fstab_configuration_misorderings(configpath: str) -> typing.List[typing. mount_point = line.split()[1] mount_points_order[mount_point] = iter - misorderings = [] + misorderings: typing.List[typing.Tuple[str, str]] = [] for mount_point in mount_points_order.keys(): if mount_point == "/": continue - if "/" in mount_points_order and mount_points_order["/"] > mount_points_order[mount_point]: - misorderings.append(("/", mount_point)) + parent_dir: str = mount_point + should_proceed: bool = True - parent_dir = os.path.dirname(mount_point) - while parent_dir != "/": + while should_proceed: + parent_dir = os.path.dirname(parent_dir) if parent_dir in mount_points_order and mount_points_order[parent_dir] > mount_points_order[mount_point]: misorderings.append((parent_dir, mount_point)) - parent_dir = os.path.dirname(parent_dir) + if parent_dir == "/": + should_proceed = False return misorderings