From a0980afff1d2458d348e144cb0d8351f862564c1 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 29 Mar 2021 17:32:48 +0200 Subject: Experimenting with carrying over flags across cache flush. This to solve issues when flush is cleared and target mountpoints gets lost, making it impossible to do .find_mountpoint('/') later on for instance. --- archinstall/lib/disk.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'archinstall') diff --git a/archinstall/lib/disk.py b/archinstall/lib/disk.py index d6d28935..84a4ff37 100644 --- a/archinstall/lib/disk.py +++ b/archinstall/lib/disk.py @@ -130,7 +130,20 @@ class BlockDevice(): return False def flush_cache(self): + old_partitions = {**self.partitions} + self.part_cache = OrderedDict() + # Trigger a refresh of the cache + if len(self.partitions): + pass + + # Carry over any flags from the previous partitions + for partition in old_partitions: + if partition in self.part_cache: + if self.part_cache[partition].size == old_partitions[partition].size and \ + self.part_cache[partition].filesystem == old_partitions[partition].filesystem: + print('Carrying over', self.part_cache[partition].target_mountpoint) + self.part_cache[partition].target_mountpoint = old_partitions[partition].target_mountpoint class Partition(): def __init__(self, path :str, block_device :BlockDevice, part_id=None, size=-1, filesystem=None, mountpoint=None, encrypted=False, autodetect_filesystem=True): @@ -237,7 +250,9 @@ class Partition(): return True if files > 0 else False def safe_to_format(self): - if self.block_device and self.block_device.keep_partitions is True: + if self.block_device and self.block_device.keep_partitions is False: + # If we don't intend to keep any partitions on the parent block device + # We're good to format. return True if self.allow_formatting is False: @@ -325,6 +340,7 @@ class Partition(): else: raise UnknownFilesystemFormat(f"Fileformat '{filesystem}' is not yet implemented.") + # self.encrypted = False if self.filesystem != 'crypto_LUKS' else True if self.block_device: self.block_device.flush_cache() -- cgit v1.2.3-54-g00ecf