Skip to content

Commit

Permalink
Make cache-copy operation more robust with extra checks.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronald-jaepel committed Nov 15, 2024
1 parent 812d240 commit 12a1fdb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cadetrdm/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,13 +1157,16 @@ def copy_data_to_cache(self, branch_name=None):
:return:
"""
previous_branch = None
has_stashed_changes = False
try:
source_filepath = self.output_repo.path

if branch_name is None:
branch_name = self.output_repo.active_branch.name
else:
self.output_repo.stash_all_changes()
if self.test_for_uncommitted_changes():
self.output_repo.stash_all_changes()
has_stashed_changes = True
previous_branch = self.output_repo.active_branch.name
self.output_repo.checkout(branch_name)

Expand All @@ -1183,10 +1186,11 @@ def copy_data_to_cache(self, branch_name=None):
finally:
if previous_branch is not None:
self.output_repo.checkout(previous_branch)
try:
self.output_repo.apply_stashed_changes()
except:
pass
if has_stashed_changes:
try:
self.output_repo.apply_stashed_changes()
except:
pass

def exit_context(self, message):
"""
Expand Down

0 comments on commit 12a1fdb

Please sign in to comment.