1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-31 03:31:41 +00:00

Smarter buffer handling.

This commit is contained in:
Jonas Borgström 2010-03-01 22:16:07 +01:00
parent 8416de6219
commit ef4a035e53

View file

@ -40,7 +40,7 @@ def __iter__(self):
self.full_sum = True self.full_sum = True
self.extra = None self.extra = None
self.done = False self.done = False
self.buf_size = self.chunk_size * 3 self.buf_size = self.chunk_size * 10
return self return self
def next(self): def next(self):
@ -51,8 +51,11 @@ def next(self):
self.done = True self.done = True
return self.extra return self.extra
while True: while True:
if self.i > self.buf_size - self.chunk_size:
self.data = self.data[self.i - o:]
self.i = o
if len(self.data) - self.i < self.chunk_size: if len(self.data) - self.i < self.chunk_size:
self.data += self.fd.read(self.chunk_size * 3) self.data += self.fd.read(self.buf_size - len(self.data))
if len(self.data) == self.i: if len(self.data) == self.i:
raise StopIteration raise StopIteration
if self.full_sum or len(self.data) - self.i < self.chunk_size: if self.full_sum or len(self.data) - self.i < self.chunk_size: