From d282e8d5d6e6b3b64915d949e176f3d04e322425 Mon Sep 17 00:00:00 2001 From: Sean C Date: Mon, 17 Apr 2023 00:33:35 -0400 Subject: [PATCH] Handle errors --- duplicateCheck.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/duplicateCheck.py b/duplicateCheck.py index f4d858a..ecb0393 100644 --- a/duplicateCheck.py +++ b/duplicateCheck.py @@ -5,12 +5,15 @@ directories = os.listdir('.') ## Get the files in the current directory files = [] def quickhash(filefullpath): - with open(filefullpath, "rb" ) as f: - md5 = hashlib.md5() - block_size=1024*100 - data = f.read(block_size) - md5.update(data) - return md5.digest() + try: + with open(filefullpath, "rb" ) as f: + md5 = hashlib.md5() + block_size=1024*100 + data = f.read(block_size) + md5.update(data) + return md5.digest() + except OSError as er: + print(f"Error hashing {filefullpath}") def direcCrawler(): global directories, files