From 228a8099a38b33b7e91ff5bfe8238146c9e821b0 Mon Sep 17 00:00:00 2001 From: Nick Todd Date: Wed, 24 Apr 2024 17:27:27 +0100 Subject: [PATCH] #2299: Revert changes to disable check_hash() --- src/primaite/simulator/file_system/file.py | 4 ++++ src/primaite/simulator/file_system/folder.py | 10 +++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/primaite/simulator/file_system/file.py b/src/primaite/simulator/file_system/file.py index f1df87fb..52fe4f85 100644 --- a/src/primaite/simulator/file_system/file.py +++ b/src/primaite/simulator/file_system/file.py @@ -166,6 +166,10 @@ class File(FileSystemItemABC): if self.previous_hash is None: self.previous_hash = current_hash + # if the previous hash and current hash do not match, mark file as corrupted + if self.previous_hash is not current_hash: + self.corrupt() + return True def repair(self) -> bool: diff --git a/src/primaite/simulator/file_system/folder.py b/src/primaite/simulator/file_system/folder.py index 64b4a91d..9f176660 100644 --- a/src/primaite/simulator/file_system/folder.py +++ b/src/primaite/simulator/file_system/folder.py @@ -388,17 +388,17 @@ class Folder(FileSystemItemABC): return False # iterate through the files and run a check hash - # no_corrupted_files = True + no_corrupted_files = True for file_id in self.files: file = self.get_file_by_id(file_uuid=file_id) file.check_hash() - # if file.health_status == FileSystemItemHealthStatus.CORRUPT: - # no_corrupted_files = False + if file.health_status == FileSystemItemHealthStatus.CORRUPT: + no_corrupted_files = False # if one file in the folder is corrupted, set the folder status to corrupted - # if not no_corrupted_files: - # self.corrupt() + if not no_corrupted_files: + self.corrupt() self.sys_log.info(f"Checking hash of folder {self.name} (id: {self.uuid})") return True