Skip to content

Commit

Permalink
enh: increased verbosity when encountering exceptions during hash check
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Aug 21, 2024
1 parent 5c6c089 commit 6fee107
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 6 additions & 0 deletions mpl_data_cast/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
20 changes: 15 additions & 5 deletions mpl_data_cast/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 6fee107

Please sign in to comment.