mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-04 14:31:13 +02:00
Do not use the md5 from cache for a missing image
This commit is contained in:
1 parent
4aadfa3b67
commit
a8e69d9a0b
2 files changed
+25
-9
No files matched your search
@@ -27,7 +27,7 @@ def md5sum(path):
|
||||
:returns: Digest of the image
|
||||
"""
|
||||
|
||||
if path is None or len(path) == 0:
|
||||
if path is None or len(path) == 0 or not os.path.exists(path):
|
||||
return None
|
||||
|
||||
try:
|
||||
@@ -36,14 +36,18 @@ def md5sum(path):
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
m = hashlib.md5()
|
||||
with open(path, 'rb') as f:
|
||||
while True:
|
||||
buf = f.read(128)
|
||||
if not buf:
|
||||
break
|
||||
m.update(buf)
|
||||
digest = m.hexdigest()
|
||||
try:
|
||||
m = hashlib.md5()
|
||||
with open(path, 'rb') as f:
|
||||
while True:
|
||||
buf = f.read(128)
|
||||
if not buf:
|
||||
break
|
||||
m.update(buf)
|
||||
digest = m.hexdigest()
|
||||
except OSError as e:
|
||||
log.error("Can't create digest of %s: %s", path, str(e))
|
||||
return None
|
||||
|
||||
try:
|
||||
with open('{}.md5sum'.format(path), 'w+') as f:
|
||||
|
||||
Reference in new issue
Block a user