diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/hydrilla/proxy/state.py | 4 | ||||
-rw-r--r-- | src/hydrilla/proxy/state_impl/items.py | 38 | ||||
-rw-r--r-- | src/hydrilla/proxy/state_impl/payloads.py | 37 |
3 files changed, 46 insertions, 33 deletions
diff --git a/src/hydrilla/proxy/state.py b/src/hydrilla/proxy/state.py index a94cd75..7613d54 100644 --- a/src/hydrilla/proxy/state.py +++ b/src/hydrilla/proxy/state.py @@ -311,6 +311,10 @@ class MappingVersionRef(Ref, item_infos.CorrespondsToMappingDCMixin): ... @abstractmethod + def ensure_depended_items_installed(self) -> None: + ... + + @abstractmethod def update_mapping_status( self, enabled: EnabledStatus, diff --git a/src/hydrilla/proxy/state_impl/items.py b/src/hydrilla/proxy/state_impl/items.py index 08c3114..02508f8 100644 --- a/src/hydrilla/proxy/state_impl/items.py +++ b/src/hydrilla/proxy/state_impl/items.py @@ -413,6 +413,44 @@ class ConcreteMappingVersionRef(st.MappingVersionRef): def uninstall(self) -> t.Optional['ConcreteMappingVersionRef']: return _uninstall_version(self) + def ensure_depended_items_installed(self) -> None: + with self.state.cursor(transaction=True) as cursor: + cursor.execute( + ''' + UPDATE + item_versions + SET + installed = 'I' + WHERE + item_version_id = ?; + ''', + (self.id,) + ) + + cursor.execute( + ''' + WITH depended_resource_ids AS ( + SELECT + rdd.resource_item_id + FROM + payloads AS p + JOIN resolved_depended_resources AS rdd + USING (payload_id) + WHERE + p.mapping_item_id = ? + ) + UPDATE + item_versions + SET + installed = 'I' + WHERE + item_version_id IN depended_resource_ids; + ''', + (self.id,) + ) + + self.state.pull_missing_files() + @contextmanager def _mapping_ref(self) -> t.Iterator[ConcreteMappingRef]: with self.state.cursor(transaction=True) as cursor: diff --git a/src/hydrilla/proxy/state_impl/payloads.py b/src/hydrilla/proxy/state_impl/payloads.py index ffd0ab3..74b8121 100644 --- a/src/hydrilla/proxy/state_impl/payloads.py +++ b/src/hydrilla/proxy/state_impl/payloads.py @@ -174,41 +174,12 @@ class ConcretePayloadRef(st.PayloadRef): (mapping_version_id,), = rows - cursor.execute( - ''' - UPDATE - item_versions - SET - installed = 'I' - WHERE - item_version_id = ?; - ''', - (mapping_version_id,) - ) - - cursor.execute( - ''' - WITH depended_resource_ids AS ( - SELECT - rdd.resource_item_id - FROM - payloads AS p - JOIN resolved_depended_resources AS rdd - USING (payload_id) - WHERE - payload_id = ? - ) - UPDATE - item_versions - SET - installed = 'I' - WHERE - item_version_id IN depended_resource_ids; - ''', - (self.id,) + mapping_version_ref = items.ConcreteMappingVersionRef( + id = str(mapping_version_id), + state = self.state ) - self.state.pull_missing_files() + mapping_version_ref.ensure_depended_items_installed() def get_script_paths(self) \ -> t.Iterable[t.Sequence[str]]: |