allow getfile to handle files > 2G

This commit is contained in:
Jay Greguske 2010-10-21 17:05:32 -04:00 committed by Mike Bonnet
parent 2f2a7d0379
commit 3bcbfa3b3d
2 changed files with 10 additions and 5 deletions

View file

@ -6746,11 +6746,12 @@ class RootExports(object):
raise koji.GenericError, 'no file "%s" output by task %i' % (fileName, taskID)
# Let the caller handler any IO or permission errors
f = file(filePath, 'r')
if isinstance(offset, int):
if offset > 0:
f.seek(offset, 0)
elif offset < 0:
f.seek(offset, 2)
if isinstance(offset, str):
offset = int(offset)
if offset != None and offset > 0:
f.seek(offset, 0)
elif offset != None and offset < 0:
f.seek(offset, 2)
contents = f.read(size)
f.close()
return base64.encodestring(contents)

View file

@ -709,7 +709,11 @@ def getfile(req, taskID, name, offset=None, size=None):
chunk_size = 1048576
if remaining < chunk_size:
chunk_size = remaining
if offset > 2147483647:
offset = str(offset)
content = server.downloadTaskOutput(taskID, name, offset=offset, size=chunk_size)
if isinstance(offset, str):
offset = int(offset)
if not content:
break
req.write(content)