diff --git a/app/main.py b/app/main.py index 34e6aef..c353c98 100755 --- a/app/main.py +++ b/app/main.py @@ -27,7 +27,7 @@ async def hook(req: Request): pack.pull() pack.collate() pack.compress() - pack.hash() + pack.hashPack() pack.upload() return "Updated " + pack.gethash() diff --git a/app/pack.py b/app/pack.py index c0119cd..c923f3b 100755 --- a/app/pack.py +++ b/app/pack.py @@ -49,18 +49,24 @@ class Pack: print("Compressing") shutil.make_archive("files/pack", 'zip', "files/pack") shutil.rmtree("files/pack") + print("Compressed") - def hash(self): - print("Hashing") - sha1sum = hashlib.sha1() - with open("files/pack.zip", "rb") as pack: - block = pack.read(2**16) - while len(block) != 0: - sha1sum.update(block) + def hashPack(self): + try: + print("Hashing") + sha1sum = hashlib.sha1() + with open("files/pack.zip", "rb") as pack: block = pack.read(2**16) - self.hash = sha1sum.hexdigest() - with open("files/hash", 'w') as hashfile: - hashfile.write(self.hash) + while len(block) != 0: + sha1sum.update(block) + block = pack.read(2**16) + self.hash = sha1sum.hexdigest() + print("Write hash") + with open("files/hash", 'w') as hashfile: + hashfile.write(self.hash) + except Exception: + print("Failed to hash") + def upload(self): print("Uploading") diff --git a/app/test/test_pack.py b/app/test/test_pack.py index fed70d1..1ed8886 100644 --- a/app/test/test_pack.py +++ b/app/test/test_pack.py @@ -7,6 +7,6 @@ def test_pack(): pack.pull() pack.collate() pack.compress() - pack.hash() + pack.hashPack() pack.upload()