From 5eecdfa13363a6bcbb94a8181818f389f41619e2 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Fri, 19 Jul 2024 19:45:57 +0200 Subject: [PATCH] key export: fix crash when no path is given In this case, the export functions output to stdout. Also: add a note why this code is needed. --- src/borg/archiver/key_cmds.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/borg/archiver/key_cmds.py b/src/borg/archiver/key_cmds.py index 1afa666a3..9dec5a5d2 100644 --- a/src/borg/archiver/key_cmds.py +++ b/src/borg/archiver/key_cmds.py @@ -97,7 +97,9 @@ class KeysMixIn: manager.export_paperkey(args.path) else: try: - if os.path.isdir(args.path): + if args.path is not None and os.path.isdir(args.path): + # on Windows, Python raises PermissionError instead of IsADirectoryError + # (like on Unix) if the file to open is actually a directory. raise IsADirectoryError if args.qr: manager.export_qr(args.path)