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