Don't read upgrade progress file if size hasn't changed

apparently that is possible sometimes?  or perhaps just an issue on python 3?
This commit is contained in:
Lance Edgar 2018-07-02 12:06:09 -05:00
parent 4c2f1aa4ed
commit 6febd01e76

View file

@ -343,12 +343,13 @@ class UpgradeView(MasterView):
offset = session.get('stdout.offset', 0) offset = session.get('stdout.offset', 0)
if os.path.exists(path): if os.path.exists(path):
size = os.path.getsize(path) - offset size = os.path.getsize(path) - offset
with open(path, 'rb') as f: if size:
f.seek(offset) with open(path, 'rb') as f:
chunk = f.read(size) f.seek(offset)
data['stdout'] = chunk.decode('utf8').replace('\n', '<br />') chunk = f.read(size)
session['stdout.offset'] = offset + size data['stdout'] = chunk.decode('utf8').replace('\n', '<br />')
session.save() session['stdout.offset'] = offset + size
session.save()
return data return data