ipxe should be done. untested currently
This commit is contained in:
12
_base.py
12
_base.py
@@ -102,8 +102,8 @@ class BaseUpdater(object):
|
||||
with open(_tmpfile, 'wb') as fh:
|
||||
for chunk in req.iter_content(chunk_size = 8192):
|
||||
fh.write(chunk)
|
||||
realhash = self.getISOHash()
|
||||
if realhash != self.new_hash:
|
||||
realhash = self.getISOHash(_tmpfile)
|
||||
if self.new_hash and realhash != self.new_hash:
|
||||
os.remove(_tmpfile)
|
||||
raise RuntimeError('Hash mismatch: {0} (LOCAL), {1} (REMOTE)'.format(realhash, self.new_hash))
|
||||
os.makedirs(os.path.dirname(self.dest_iso), exist_ok = True)
|
||||
@@ -117,10 +117,14 @@ class BaseUpdater(object):
|
||||
raise RuntimeError('BaseUpdater should be subclassed and its updateVer, getCurVer, and getNewVer methods '
|
||||
'should be replaced.')
|
||||
|
||||
def getISOHash(self):
|
||||
def getISOHash(self, filepath = None):
|
||||
if not filepath:
|
||||
filepath = self.dest_iso
|
||||
else:
|
||||
filepath = os.path.abspath(os.path.expanduser(filepath))
|
||||
hasher = hashlib.new(self.hash_type)
|
||||
# TODO: later on when python 3.8 is more prevalent, https://stackoverflow.com/a/1131238/733214
|
||||
with open(self.dest_iso, 'rb') as fh:
|
||||
with open(filepath, 'rb') as fh:
|
||||
while True:
|
||||
chunk = fh.read(8192)
|
||||
if not chunk:
|
||||
|
||||
Reference in New Issue
Block a user