Fix for older python versions

The "walrus" operator is only available in python 3.8 and later. Fall back to more traditional notation.
This commit is contained in:
glubsy 2021-08-13 20:56:33 +02:00
parent 7b764f183e
commit 545a5a75fb
1 changed files with 6 additions and 1 deletions

View File

@ -138,8 +138,13 @@ class File:
try:
with self.path.open("rb") as fp:
md5 = hashlib.md5()
while filedata := fp.read(CHUNK_SIZE):
filedata = fp.read(CHUNK_SIZE)
while filedata:
md5.update(filedata)
filedata = fp.read(CHUNK_SIZE)
# FIXME For python 3.8 and later
# while filedata := fp.read(CHUNK_SIZE):
# md5.update(filedata)
self.md5 = md5.digest()
except Exception:
pass