Retry unmounting

This commit is contained in:
PapaTutuWawa 2023-12-22 00:43:23 +01:00
parent f72e786efa
commit a79006dc41

View File

@ -102,27 +102,31 @@ class OverlayFSMount:
self._mounted = True self._mounted = True
return self.mount_path return self.mount_path
def unmount(self): def unmount(self) -> bool:
if self._mounted: if self._mounted:
print("Unmounting...") print("Unmounting...")
# Remove the mount # Remove the mount
if LMMConfig.use_fuse: if LMMConfig.use_fuse:
run_cmd( returncode = run_cmd(
[ [
LMMConfig.fusermount_command, LMMConfig.fusermount_command,
"-u", "-u",
str(self.mount_path), str(self.mount_path),
] ]
) ) == 0
else: else:
run_sudo_cmd( returncode = run_sudo_cmd(
[ [
"umount", "umount",
str(self.mount_path), str(self.mount_path),
] ]
) )
if returncode != 0:
print("Unmounting failed")
return False
# Remove the temporary workdir # Remove the temporary workdir
if self.workdir is not None: if self.workdir is not None:
try: try:
@ -132,6 +136,7 @@ class OverlayFSMount:
print(f"Failed to clean temporary directory {self.workdir.name}") print(f"Failed to clean temporary directory {self.workdir.name}")
self._mounted = False self._mounted = False
return True
def __del__(self): def __del__(self):
self.unmount() self.unmount()