|
@@ -405,9 +405,10 @@ class Archive:
|
|
chunks = [cache.chunk_incref(id_, self.stats) for id_ in ids]
|
|
chunks = [cache.chunk_incref(id_, self.stats) for id_ in ids]
|
|
# Only chunkify the file if needed
|
|
# Only chunkify the file if needed
|
|
if chunks is None:
|
|
if chunks is None:
|
|
- with Archive._open_rb(path, st) as fd:
|
|
|
|
|
|
+ fh = Archive._open_rb(path, st)
|
|
|
|
+ with os.fdopen(fh, 'rb') as fd:
|
|
chunks = []
|
|
chunks = []
|
|
- for chunk in self.chunker.chunkify(fd):
|
|
|
|
|
|
+ for chunk in self.chunker.chunkify(fd, fh):
|
|
chunks.append(cache.add_chunk(self.key.id_hash(chunk), chunk, self.stats))
|
|
chunks.append(cache.add_chunk(self.key.id_hash(chunk), chunk, self.stats))
|
|
cache.memorize_file(path_hash, st, [c[0] for c in chunks])
|
|
cache.memorize_file(path_hash, st, [c[0] for c in chunks])
|
|
item = {b'path': safe_path, b'chunks': chunks}
|
|
item = {b'path': safe_path, b'chunks': chunks}
|
|
@@ -427,12 +428,10 @@ class Archive:
|
|
euid = None
|
|
euid = None
|
|
|
|
|
|
def open_simple(p, s):
|
|
def open_simple(p, s):
|
|
- fd = os.open(p, flags_normal)
|
|
|
|
- return os.fdopen(fd, 'rb')
|
|
|
|
|
|
+ return os.open(p, flags_normal)
|
|
|
|
|
|
def open_noatime(p, s):
|
|
def open_noatime(p, s):
|
|
- fd = os.open(p, flags_noatime)
|
|
|
|
- return os.fdopen(fd, 'rb')
|
|
|
|
|
|
+ return os.open(p, flags_noatime)
|
|
|
|
|
|
def open_noatime_if_owner(p, s):
|
|
def open_noatime_if_owner(p, s):
|
|
if euid == 0 or s.st_uid == euid:
|
|
if euid == 0 or s.st_uid == euid:
|
|
@@ -454,7 +453,7 @@ class Archive:
|
|
# So in future, let's check whether the file is owned by us
|
|
# So in future, let's check whether the file is owned by us
|
|
# before attempting to use O_NOATIME.
|
|
# before attempting to use O_NOATIME.
|
|
Archive._open_rb = open_noatime_if_owner
|
|
Archive._open_rb = open_noatime_if_owner
|
|
- return os.fdopen(fd, 'rb')
|
|
|
|
|
|
+ return fd
|
|
|
|
|
|
if flags_noatime != flags_normal:
|
|
if flags_noatime != flags_normal:
|
|
# Always use O_NOATIME version.
|
|
# Always use O_NOATIME version.
|