1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-13 07:33:47 +00:00

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.
This commit is contained in:
Thomas Waldmann 2024-09-16 12:01:41 +02:00
parent de249f611e
commit 8790371ac8
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 3 additions and 2 deletions

View file

@ -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,

View file

@ -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"):