Selaa lähdekoodia

Emit user-friendly error if repo key is exported to a directory (fixes #4348)

Milkey Mouse 6 vuotta sitten
vanhempi
sitoutus
72ebd13e6f
1 muutettua tiedostoa jossa 8 lisäystä ja 4 poistoa
  1. 8 4
      src/borg/archiver.py

+ 8 - 4
src/borg/archiver.py

@@ -325,10 +325,14 @@ class Archiver:
             if not args.path:
             if not args.path:
                 self.print_error("output file to export key to expected")
                 self.print_error("output file to export key to expected")
                 return EXIT_ERROR
                 return EXIT_ERROR
-            if args.qr:
-                manager.export_qr(args.path)
-            else:
-                manager.export(args.path)
+            try:
+                if args.qr:
+                    manager.export_qr(args.path)
+                else:
+                    manager.export(args.path)
+            except IsADirectoryError:
+                self.print_error("'{}' must be a file, not a directory".format(args.path))
+                return EXIT_ERROR
         return EXIT_SUCCESS
         return EXIT_SUCCESS
 
 
     @with_repository(lock=False, exclusive=False, manifest=False, cache=False)
     @with_repository(lock=False, exclusive=False, manifest=False, cache=False)