extract: chown only if we have u/g info in archived item, see #7249

also: move get_item_uid_gid() to "not is_win32" block for now.
This commit is contained in:
Thomas Waldmann 2023-01-15 00:28:29 +01:00
parent 1f9c46f2b5
commit 4dcc48f5c4
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
1 changed files with 5 additions and 2 deletions

View File

@ -928,9 +928,12 @@ Duration: {0.duration}
Does not access the repository.
"""
backup_io.op = "attrs"
uid, gid = get_item_uid_gid(item, numeric=self.numeric_ids)
# This code is a bit of a mess due to os specific differences
# This code is a bit of a mess due to OS specific differences.
if not is_win32:
# by using uid_default = -1 and gid_default = -1, they will not be restored if
# the archived item has no information about them.
uid, gid = get_item_uid_gid(item, numeric=self.numeric_ids, uid_default=-1, gid_default=-1)
# if uid and/or gid is -1, chown will keep it as is and not change it.
try:
if fd:
os.fchown(fd, uid, gid)