|
@@ -392,14 +392,14 @@ def get_item_uid_gid(item, *, numeric, uid_forced=None, gid_forced=None, uid_def
|
|
|
if uid_forced is not None:
|
|
|
uid = uid_forced
|
|
|
else:
|
|
|
- uid = None if numeric else user2uid(item.user)
|
|
|
+ uid = None if numeric else user2uid(item.get('user'))
|
|
|
uid = item.uid if uid is None else uid
|
|
|
if uid < 0:
|
|
|
uid = uid_default
|
|
|
if gid_forced is not None:
|
|
|
gid = gid_forced
|
|
|
else:
|
|
|
- gid = None if numeric else group2gid(item.group)
|
|
|
+ gid = None if numeric else group2gid(item.get('group'))
|
|
|
gid = item.gid if gid is None else gid
|
|
|
if gid < 0:
|
|
|
gid = gid_default
|
|
@@ -1089,11 +1089,13 @@ class MetadataCollector:
|
|
|
if not self.nobirthtime and hasattr(st, 'st_birthtime'):
|
|
|
# sadly, there's no stat_result.st_birthtime_ns
|
|
|
attrs['birthtime'] = safe_ns(int(st.st_birthtime * 10**9))
|
|
|
- if self.numeric_ids:
|
|
|
- attrs['user'] = attrs['group'] = None
|
|
|
- else:
|
|
|
- attrs['user'] = uid2user(st.st_uid)
|
|
|
- attrs['group'] = gid2group(st.st_gid)
|
|
|
+ if not self.numeric_ids:
|
|
|
+ user = uid2user(st.st_uid)
|
|
|
+ if user is not None:
|
|
|
+ attrs['user'] = user
|
|
|
+ group = gid2group(st.st_gid)
|
|
|
+ if group is not None:
|
|
|
+ attrs['group'] = group
|
|
|
return attrs
|
|
|
|
|
|
def stat_ext_attrs(self, st, path, fd=None):
|
|
@@ -1426,8 +1428,11 @@ class TarfileObjectProcessors:
|
|
|
return safe_ns(int(float(s) * 1e9))
|
|
|
|
|
|
item = Item(path=make_path_safe(tarinfo.name), mode=tarinfo.mode | type,
|
|
|
- uid=tarinfo.uid, gid=tarinfo.gid, user=tarinfo.uname or None, group=tarinfo.gname or None,
|
|
|
- mtime=s_to_ns(tarinfo.mtime))
|
|
|
+ uid=tarinfo.uid, gid=tarinfo.gid, mtime=s_to_ns(tarinfo.mtime))
|
|
|
+ if tarinfo.uname:
|
|
|
+ item.user = tarinfo.uname
|
|
|
+ if tarinfo.gname:
|
|
|
+ item.group = tarinfo.gname
|
|
|
if ph:
|
|
|
# note: for mtime this is a bit redundant as it is already done by tarfile module,
|
|
|
# but we just do it in our way to be consistent for sure.
|