diff --git a/libkeyringctl/cli.py b/libkeyringctl/cli.py index 881c666..5fa9087 100644 --- a/libkeyringctl/cli.py +++ b/libkeyringctl/cli.py @@ -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, diff --git a/libkeyringctl/keyring.py b/libkeyringctl/keyring.py index 07f9768..5c2128a 100644 --- a/libkeyringctl/keyring.py +++ b/libkeyringctl/keyring.py @@ -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)