fix(keyrinctl): yield file not found errors instead of blocking on stdin
Handle missing or wrong certificate paths in a way that does not lead to a blocking command by reading from stdin. Instead throw either file not found errors or expect optional outputs.
This commit is contained in:
parent
58307c629d
commit
94c3b4c8e9
@ -133,15 +133,17 @@ def main() -> None:
|
||||
)
|
||||
)
|
||||
elif "export" == args.subcommand:
|
||||
print(
|
||||
export(
|
||||
working_dir=working_dir,
|
||||
keyring_root=keyring_root,
|
||||
sources=args.source,
|
||||
output=args.output,
|
||||
),
|
||||
end="",
|
||||
result = export(
|
||||
working_dir=working_dir,
|
||||
keyring_root=keyring_root,
|
||||
sources=args.source,
|
||||
output=args.output,
|
||||
)
|
||||
if result:
|
||||
print(
|
||||
result,
|
||||
end="",
|
||||
)
|
||||
elif "build" == args.subcommand:
|
||||
build(
|
||||
working_dir=working_dir,
|
||||
|
@ -62,8 +62,6 @@ def get_cert_paths(paths: Iterable[Path]) -> Set[Path]:
|
||||
visit: List[Path] = list(paths)
|
||||
while visit:
|
||||
path = visit.pop()
|
||||
if not path.exists():
|
||||
continue
|
||||
# this level contains a certificate, abort depth search
|
||||
if list(path.glob("*.asc")):
|
||||
cert_paths.add(path)
|
||||
@ -580,7 +578,7 @@ def convert(
|
||||
get_fingerprints(
|
||||
working_dir=working_dir,
|
||||
sources=source,
|
||||
paths=[keyring_root],
|
||||
paths=[keyring_root] if keyring_root.exists() else [],
|
||||
).keys()
|
||||
)
|
||||
|
||||
@ -832,7 +830,7 @@ def export(
|
||||
keyring_root: Path,
|
||||
sources: Optional[List[Path]] = None,
|
||||
output: Optional[Path] = None,
|
||||
) -> str:
|
||||
) -> Optional[str]:
|
||||
"""Export all provided PGP packet files to a single output file
|
||||
|
||||
If sources contains directories, any .asc files below them are considered.
|
||||
@ -876,6 +874,9 @@ def export(
|
||||
)
|
||||
certificates.append(output_path)
|
||||
|
||||
if not certificates:
|
||||
return None
|
||||
|
||||
return keyring_merge(certificates, output, force=True)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user