inline all messages
This commit is contained in:
+2
-3
@@ -3,7 +3,6 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
from uuid import UUID
|
||||
|
||||
from .messages import ALREADY_DECRYPTED, NOT_DECRYPTED
|
||||
from .commands.cryptsetup import Cryptsetup
|
||||
from .misc import DISK_BY_UUID
|
||||
|
||||
@@ -18,7 +17,7 @@ class Disk:
|
||||
def decrypt(self) -> None:
|
||||
"""Open a LUKS-encrypted disk with `cryptsetup`. Silently pass if it was already decrypted."""
|
||||
if self._decrypted:
|
||||
raise ValueError(ALREADY_DECRYPTED, self._name)
|
||||
raise ValueError("Cannot decrypt, already decrypted", self._name)
|
||||
self._was_already_decrypted = Cryptsetup.decrypt(self._path, self._mapper_entry)
|
||||
self._decrypted = True
|
||||
|
||||
@@ -35,7 +34,7 @@ class Disk:
|
||||
def encrypt(self) -> None:
|
||||
"""Close a LUKS-encrypted container with `cryptsetup`."""
|
||||
if not self._decrypted:
|
||||
raise ValueError(NOT_DECRYPTED, self._name)
|
||||
raise ValueError("Cannot encrypt, not decrypted", self._name)
|
||||
if self._was_already_decrypted:
|
||||
return
|
||||
Cryptsetup.encrypt(self._mapper_entry)
|
||||
|
||||
Reference in New Issue
Block a user