diff --git a/CHANGELOG b/CHANGELOG index 9dd6fca..20ba21b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +0.7.3 + - enh: increased verbosity when encountering exceptions during hash check 0.7.2 - fix: remove unnecessary print-calls 0.7.1 diff --git a/mpl_data_cast/recipe.py b/mpl_data_cast/recipe.py index 4e4a571..99d2018 100644 --- a/mpl_data_cast/recipe.py +++ b/mpl_data_cast/recipe.py @@ -262,7 +262,12 @@ def transfer_to_target_path(temp_path: pathlib.Path, thr_in.start() thr_in.join() hash_input = thr_in.hash + if thr_in.error: + raise ValueError(thr_in.error) + thr_out.join() + if thr_out.error: + raise ValueError(thr_out.error) hash_target = thr_out.hash # sanity check @@ -276,6 +281,7 @@ def transfer_to_target_path(temp_path: pathlib.Path, # Since we copied the wrong file, we are responsible for # deleting it. target_path.unlink(missing_ok=True) + if success and delete_after: temp_path.unlink(missing_ok=True) return success diff --git a/mpl_data_cast/util.py b/mpl_data_cast/util.py index 9799deb..7e04203 100644 --- a/mpl_data_cast/util.py +++ b/mpl_data_cast/util.py @@ -29,13 +29,23 @@ def __init__(self, path, copy_to=None, *args, **kwargs): self.path = path self.copy_to = copy_to self.hash = None + self.error = None def run(self): - if self.copy_to: - self.hash = copyhashfile(path_in=self.path, - path_out=self.copy_to) - else: - self.hash = hashfile(self.path) + for ii in range(3): + try: + if self.copy_to: + self.hash = copyhashfile(path_in=self.path, + path_out=self.copy_to) + else: + self.hash = hashfile(self.path) + except BaseException: + self.error = traceback.format_exc() + logger.error(self.error) + time.sleep(10) + else: + self.error = None + break def copyhashfile(path_in: str | pathlib.Path,