process_pipe: allow creating item w/o user/group/uid/gid, see #7249

This commit is contained in:
Thomas Waldmann 2023-01-15 00:05:50 +01:00
parent 262812e76f
commit b338eb0ce8
No known key found for this signature in database
GPG Key ID: 243ACFA951F78E01
1 changed files with 22 additions and 18 deletions

View File

@ -1399,28 +1399,32 @@ class FilesystemObjectProcessors:
item.update(self.metadata_collector.stat_attrs(st, path)) # can't use FD here?
return status
def process_pipe(self, *, path, cache, fd, mode, user, group):
def process_pipe(self, *, path, cache, fd, mode, user=None, group=None):
status = "i" # stdin (or other pipe)
self.print_file_status(status, path)
status = None # we already printed the status
if user is not None:
uid = user2uid(user)
if uid is None:
raise Error("no such user: %s" % user)
else:
uid = None
if group is not None:
gid = group2gid(group)
if gid is None:
raise Error("no such group: %s" % group)
else:
gid = None
t = int(time.time()) * 1000000000
item = Item(
path=path,
mode=mode & 0o107777 | 0o100000, # forcing regular file mode
uid=uid,
user=user,
gid=gid,
group=group,
mtime=t,
atime=t,
ctime=t,
)
item = Item(path=path, mode=mode & 0o107777 | 0o100000, mtime=t, atime=t, ctime=t) # forcing regular file mode
if user is not None:
item.user = user
if group is not None:
item.group = group
if uid is not None:
item.uid = uid
if gid is not None:
item.gid = gid
self.process_file_chunks(item, cache, self.stats, self.show_progress, backup_io_iter(self.chunker.chunkify(fd)))
item.get_size(memorize=True)
self.stats.nfiles += 1