Skip to content

Commit

Permalink
Fix getChunks when reading gzip files.
Browse files Browse the repository at this point in the history
Since gzip files are always finished, we don't need to freeze the state
of the logfile by determining where the end of the file is.
  • Loading branch information
Chris AtLee committed Dec 4, 2009
1 parent dcbf829 commit 0a26b31
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions buildbot/status/builder.py
Expand Up @@ -334,9 +334,13 @@ def getChunks(self, channels=[], onlyText=False):
# yield() calls.

f = self.getFile()
offset = 0
f.seek(0, 2)
remaining = f.tell()
if not self.finished:
offset = 0
f.seek(0, 2)
remaining = f.tell()
else:
offset = 0
remaining = None

leftover = None
if self.runEntries and (not channels or
Expand All @@ -354,8 +358,12 @@ def _generateChunks(self, f, offset, remaining, leftover,
chunks = []
p = LogFileScanner(chunks.append, channels)
f.seek(offset)
data = f.read(min(remaining, self.BUFFERSIZE))
remaining -= len(data)
if remaining is not None:
data = f.read(min(remaining, self.BUFFERSIZE))
remaining -= len(data)
else:
data = f.read(self.BUFFERSIZE)

offset = f.tell()
while data:
p.dataReceived(data)
Expand All @@ -366,8 +374,11 @@ def _generateChunks(self, f, offset, remaining, leftover,
else:
yield (channel, text)
f.seek(offset)
data = f.read(min(remaining, self.BUFFERSIZE))
remaining -= len(data)
if remaining is not None:
data = f.read(min(remaining, self.BUFFERSIZE))
remaining -= len(data)
else:
data = f.read(self.BUFFERSIZE)
offset = f.tell()
del f

Expand Down

0 comments on commit 0a26b31

Please sign in to comment.