clan-cli: don't try to delete a dir that doesn't exist in the pass vars backend

Do not crash in `delete_store`, if the machine has no vars, or the store
has been deleted already.
This commit is contained in:
Louis Opter
2025-03-18 17:49:51 +00:00
committed by Mic92
parent 4120a89115
commit b52ec05497
2 changed files with 33 additions and 8 deletions

View File

@@ -77,8 +77,12 @@ class SecretStore(StoreBase):
return []
def delete_store(self) -> Iterable[Path]:
machine_pass_dir = Path(self.entry_prefix) / "per-machine" / self.machine.name
pass_call = ["rm", "--force", "--recursive", str(machine_pass_dir)]
machine_dir = Path(self.entry_prefix) / "per-machine" / self.machine.name
if not (self._password_store_dir / machine_dir).exists():
# The directory may not exist if the machine
# has no vars, or they have been deleted already.
return []
pass_call = ["rm", "--force", "--recursive", str(machine_dir)]
self._run_pass(*pass_call, options=RunOpts(check=True))
return []