Catching PermissionError

This commit is contained in:
Nex 2022-06-20 18:28:05 +02:00
parent 09400a2847
commit b847683717
1 changed files with 6 additions and 2 deletions

View File

@ -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,