Skip to content

Commit

Permalink
Fix WC session aliasing issue
Browse files Browse the repository at this point in the history
session & state_session are no longer the same function; one calls the
other
  • Loading branch information
craigds committed Nov 10, 2024
1 parent f8c6bbd commit 9afda4c
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions kart/working_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,7 @@ def reset(
repo_key_filter,
)

# Start a DB session that surrounds both the working copy modifications and the state table modifications -
# if the same DB session can be used for both, otherwise, let _do_reset_datasets handle it.
session_context = (
self.session
if hasattr(self, "session") and self.session == self.state_session
else contextlib.nullcontext
)
with session_context():
with self.state_session() as sess:
if ds_inserts or ds_updates or ds_deletes:
self._do_reset_datasets(
base_datasets=base_datasets,
Expand All @@ -691,15 +684,12 @@ def reset(
quiet=quiet,
)

with self.state_session() as sess:
if not track_changes_as_dirty:
self._update_state_table_tree(sess, target_tree_id)
self._update_state_table_spatial_filter_hash(
sess, self.repo.spatial_filter.hexhash
)
self._update_state_table_non_checkout_datasets(
sess, non_checkout_datasets
)
if not track_changes_as_dirty:
self._update_state_table_tree(sess, target_tree_id)
self._update_state_table_spatial_filter_hash(
sess, self.repo.spatial_filter.hexhash
)
self._update_state_table_non_checkout_datasets(sess, non_checkout_datasets)

def _do_reset_datasets(
self,
Expand Down

0 comments on commit 9afda4c

Please sign in to comment.