mirror of https://github.com/borgbackup/borg.git
Merge pull request #7287 from ThomasWaldmann/fix-get-item-uid-gid-win32
fix some uid/gid lookup code / tests for win32
This commit is contained in:
commit
ccbfc4ee95
|
@ -21,6 +21,9 @@ def uid2user(uid, default=None):
|
|||
|
||||
@lru_cache(maxsize=None)
|
||||
def user2uid(user, default=None):
|
||||
if not user:
|
||||
# user is either None or the empty string
|
||||
return default
|
||||
return 0
|
||||
|
||||
|
||||
|
@ -31,6 +34,9 @@ def gid2group(gid, default=None):
|
|||
|
||||
@lru_cache(maxsize=None)
|
||||
def group2gid(group, default=None):
|
||||
if not group:
|
||||
# group is either None or the empty string
|
||||
return default
|
||||
return 0
|
||||
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from ..archive import BackupOSError, backup_io, backup_io_iter, get_item_uid_gid
|
|||
from ..helpers import msgpack
|
||||
from ..item import Item, ArchiveItem
|
||||
from ..manifest import Manifest
|
||||
from ..platform import uid2user, gid2group
|
||||
from ..platform import uid2user, gid2group, is_win32
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
|
@ -349,6 +349,11 @@ def test_get_item_uid_gid():
|
|||
assert uid == 7
|
||||
assert gid == 8
|
||||
|
||||
if not is_win32:
|
||||
# due to the hack in borg.platform.windows user2uid / group2gid, these always return 0
|
||||
# (no matter which username we ask for) and they never raise a KeyError (like e.g. for
|
||||
# a non-existing user/group name). Thus, these tests can currently not succeed on win32.
|
||||
|
||||
# item metadata has valid uid/gid, but non-existing user/group names.
|
||||
item = Item(path="filename", uid=9, gid=10, user="udoesnotexist", group="gdoesnotexist")
|
||||
|
||||
|
|
Loading…
Reference in New Issue