Browse Source

map EISDIR to BackupPermissionError class also

macOS and Linux give EISDIR, while Windows gives EPERM when trying to
open a file for writing, if the filename is already taken by an existing
directory.

now all OSes should give the same RC in this case.
Thomas Waldmann 10 months ago
parent
commit
8790371ac8
2 changed files with 3 additions and 2 deletions
  1. 1 0
      src/borg/archive.py
  2. 2 2
      src/borg/testsuite/archiver/extract_cmd.py

+ 1 - 0
src/borg/archive.py

@@ -196,6 +196,7 @@ class BackupIO:
         if exc_type and issubclass(exc_type, OSError):
         if exc_type and issubclass(exc_type, OSError):
             E_MAP = {
             E_MAP = {
                 errno.EPERM: BackupPermissionError,
                 errno.EPERM: BackupPermissionError,
+                errno.EISDIR: BackupPermissionError,
                 errno.EACCES: BackupPermissionError,
                 errno.EACCES: BackupPermissionError,
                 errno.EBUSY: BackupPermissionError,
                 errno.EBUSY: BackupPermissionError,
                 errno.ENOENT: BackupFileNotFoundError,
                 errno.ENOENT: BackupFileNotFoundError,

+ 2 - 2
src/borg/testsuite/archiver/extract_cmd.py

@@ -9,7 +9,7 @@ import pytest
 from ... import xattr
 from ... import xattr
 from ...chunker import has_seek_hole
 from ...chunker import has_seek_hole
 from ...constants import *  # NOQA
 from ...constants import *  # NOQA
-from ...helpers import EXIT_WARNING, BackupOSError
+from ...helpers import EXIT_WARNING, BackupPermissionError
 from ...helpers import flags_noatime, flags_normal
 from ...helpers import flags_noatime, flags_normal
 from .. import changedir, same_ts_ns
 from .. import changedir, same_ts_ns
 from .. import are_symlinks_supported, are_hardlinks_supported, is_utime_fully_supported, is_birthtime_fully_supported
 from .. import are_symlinks_supported, are_hardlinks_supported, is_utime_fully_supported, is_birthtime_fully_supported
@@ -621,7 +621,7 @@ def test_overwrite(archivers, request):
     os.unlink("output/input/file1")
     os.unlink("output/input/file1")
     os.mkdir("output/input/file1")
     os.mkdir("output/input/file1")
     os.mkdir("output/input/file1/dir")
     os.mkdir("output/input/file1/dir")
-    expected_ec = BackupOSError("open", OSError(21, "is a directory")).exit_code  # WARNING code
+    expected_ec = BackupPermissionError("open", OSError(21, "is a directory")).exit_code  # WARNING code
     if expected_ec == EXIT_ERROR:  # workaround, TODO: fix it
     if expected_ec == EXIT_ERROR:  # workaround, TODO: fix it
         expected_ec = EXIT_WARNING
         expected_ec = EXIT_WARNING
     with changedir("output"):
     with changedir("output"):