fix(keyringctl): restore cwd before deleting the temporary working dir

This avoids potential issues with wrapped runtime like ipython or pdb
that try to invoke functions at exit and access the current working
directory, which will ultimately lead to an error in case we deleted it
before changing the current working directory.
This commit is contained in:
Levente Polyak 2021-10-12 19:22:30 +02:00
parent 92f07f0d4b
commit a0199b0b04
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8

View File

@ -1074,9 +1074,8 @@ if __name__ == '__main__':
# temporary working directory that gets auto cleaned # temporary working directory that gets auto cleaned
with TemporaryDirectory() as tempdir: with TemporaryDirectory() as tempdir:
working_dir = Path(tempdir) working_dir = Path(tempdir)
chdir(working_dir)
debug(f'Working directory: {working_dir}') debug(f'Working directory: {working_dir}')
with cwd(working_dir):
if args.subcommand in ["convert", "import"]: if args.subcommand in ["convert", "import"]:
if args.target: if args.target:
args.target.mkdir(parents=True, exist_ok=True) args.target.mkdir(parents=True, exist_ok=True)