Added failed umount force retry
This commit is contained in:
25
main.py
25
main.py
@@ -38,6 +38,7 @@ class AppState:
|
||||
diskEventQueue: Queue[DiskEvent] = Queue()
|
||||
diskState: DiskState = "disconnected"
|
||||
config = Config()
|
||||
failedUmount: bool = False
|
||||
|
||||
|
||||
def saveConfig(config: Config, path: Path) -> None:
|
||||
@@ -174,19 +175,31 @@ def mountDisk(state: AppState) -> None:
|
||||
|
||||
|
||||
def unmountDisk(state: AppState) -> None:
|
||||
try:
|
||||
if not state.failedUmount:
|
||||
try:
|
||||
subprocess.run(
|
||||
[
|
||||
"umount",
|
||||
f"/mnt/{state.config.diskSerial}",
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
print("unmounting disk")
|
||||
except subprocess.CalledProcessError:
|
||||
state.failedUmount = True
|
||||
else:
|
||||
state.diskState = "disconnected"
|
||||
else:
|
||||
subprocess.run(
|
||||
[
|
||||
"umount",
|
||||
"-f",
|
||||
f"/mnt/{state.config.diskSerial}",
|
||||
],
|
||||
check=True,
|
||||
check=False,
|
||||
)
|
||||
print("unmounting disk")
|
||||
except subprocess.CalledProcessError:
|
||||
pass
|
||||
else:
|
||||
state.diskState = "disconnected"
|
||||
state.failedUmount = False
|
||||
|
||||
|
||||
def main() -> None:
|
||||
|
||||
Reference in New Issue
Block a user