feature(keyringctl): use prefixed temp dirs for easier recognition

It makes sense to prefix the temp directories so they can be identified
more easily to which application they belong to or what they may
contain.
This commit is contained in:
Levente Polyak 2021-10-12 19:25:51 +02:00
parent a0199b0b04
commit 4e98585232
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8

View File

@ -675,7 +675,7 @@ def packet_split(working_dir: Path, certificate: Path) -> Iterable[Path]:
An iterable over the naturally sorted list of packet files derived from certificate An iterable over the naturally sorted list of packet files derived from certificate
""" """
packet_dir = Path(mkdtemp(dir=working_dir)).absolute() packet_dir = Path(mkdtemp(dir=working_dir, prefix='packet-')).absolute()
with cwd(packet_dir): with cwd(packet_dir):
system(['sq', 'packet', 'split', '--prefix', '', str(certificate)]) system(['sq', 'packet', 'split', '--prefix', '', str(certificate)])
@ -1072,7 +1072,7 @@ if __name__ == '__main__':
basicConfig(level=DEBUG) basicConfig(level=DEBUG)
# temporary working directory that gets auto cleaned # temporary working directory that gets auto cleaned
with TemporaryDirectory() as tempdir: with TemporaryDirectory(prefix='arch-keyringctl-') as tempdir:
working_dir = Path(tempdir) working_dir = Path(tempdir)
debug(f'Working directory: {working_dir}') debug(f'Working directory: {working_dir}')
with cwd(working_dir): with cwd(working_dir):
@ -1082,7 +1082,7 @@ if __name__ == '__main__':
target_dir = args.target target_dir = args.target
else: else:
# persistent target directory # persistent target directory
target_dir = Path(mkdtemp()).absolute() target_dir = Path(mkdtemp(prefix='arch-keyringctl-')).absolute()
if 'convert' == args.subcommand: if 'convert' == args.subcommand:
print(convert(working_dir, args.source, target_dir)) print(convert(working_dir, args.source, target_dir))