瀏覽代碼

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 8 月之前
父節點
當前提交
8790371ac8
共有 2 個文件被更改,包括 3 次插入2 次删除
  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):
             E_MAP = {
                 errno.EPERM: BackupPermissionError,
+                errno.EISDIR: BackupPermissionError,
                 errno.EACCES: BackupPermissionError,
                 errno.EBUSY: BackupPermissionError,
                 errno.ENOENT: BackupFileNotFoundError,

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

@@ -9,7 +9,7 @@ import pytest
 from ... import xattr
 from ...chunker import has_seek_hole
 from ...constants import *  # NOQA
-from ...helpers import EXIT_WARNING, BackupOSError
+from ...helpers import EXIT_WARNING, BackupPermissionError
 from ...helpers import flags_noatime, flags_normal
 from .. import changedir, same_ts_ns
 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.mkdir("output/input/file1")
     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
         expected_ec = EXIT_WARNING
     with changedir("output"):