From b8476837178aff3ba1b09622fa48ab68205b6e6c Mon Sep 17 00:00:00 2001 From: Nex Date: Mon, 20 Jun 2022 18:28:05 +0200 Subject: [PATCH] Catching PermissionError --- mvt/common/command.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mvt/common/command.py b/mvt/common/command.py index 748803e..0771f80 100644 --- a/mvt/common/command.py +++ b/mvt/common/command.py @@ -105,8 +105,12 @@ class Command(object): file_path = os.path.join(root, file) h = hashlib.sha256() - with open(file_path, "rb") as handle: - h.update(handle.read()) + try: + with open(file_path, "rb") as handle: + h.update(handle.read()) + except PermissionError: + log.error("Failed to hash the file %s: permission denied", file_path) + continue info["hashes"].append({ "file_path": file_path,