From 900507aa436bc62b7c3a8fc7cccaa3b225dad9b6 Mon Sep 17 00:00:00 2001 From: Mikhail Sandakov Date: Tue, 26 Nov 2024 09:40:21 +0200 Subject: [PATCH] fixup! fixup! Add a preliminary checker to ensure the mount points in /etc/fstab are in the correct order --- pleskdistup/common/src/mounts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pleskdistup/common/src/mounts.py b/pleskdistup/common/src/mounts.py index 16546b3..3a0c213 100644 --- a/pleskdistup/common/src/mounts.py +++ b/pleskdistup/common/src/mounts.py @@ -38,10 +38,10 @@ def get_fstab_configuration_misorderings(configpath: str) -> typing.List[typing. if mount_points_order["/"] > mount_points_order[mount_point]: misorderings.append(("/", mount_point)) - leading_paths = mount_point.split("/")[:-1] - for i in range(1, len(leading_paths) + 1): - parent_dir = "/".join(leading_paths[:i]) - if parent_dir in mount_points_order and mount_points_order[parent_dir] > mount_points_order[mount_point]: - misorderings.append((parent_dir, mount_point)) + parant_dir = os.path.dirname(mount_point) + while parant_dir != "/": + if parant_dir in mount_points_order and mount_points_order[parant_dir] > mount_points_order[mount_point]: + misorderings.append((parant_dir, mount_point)) + parant_dir = os.path.dirname(parant_dir) return misorderings