mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 03:37:28 +01:00
Game Support: Remove caching as it causes obscure issues
This commit is contained in:
parent
4302ba4bf2
commit
59fad153ae
@ -93,12 +93,10 @@ class GSPackage:
|
|||||||
class GameSupport:
|
class GameSupport:
|
||||||
packages: Dict[str, GSPackage]
|
packages: Dict[str, GSPackage]
|
||||||
modified_packages: set[GSPackage]
|
modified_packages: set[GSPackage]
|
||||||
dependency_cache: Dict[str, Tuple[Optional[bool], Optional[set[str]]]]
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.packages = {}
|
self.packages = {}
|
||||||
self.modified_packages = set()
|
self.modified_packages = set()
|
||||||
self.dependency_cache = {}
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def all_confirmed(self):
|
def all_confirmed(self):
|
||||||
@ -136,11 +134,6 @@ class GameSupport:
|
|||||||
def _get_supported_games_for_modname(self, depend: str, visited: list[str]):
|
def _get_supported_games_for_modname(self, depend: str, visited: list[str]):
|
||||||
dep_supports_all = False
|
dep_supports_all = False
|
||||||
for_dep = set()
|
for_dep = set()
|
||||||
|
|
||||||
if depend in self.dependency_cache:
|
|
||||||
dep_supports_all, for_dep = self.dependency_cache[depend]
|
|
||||||
return dep_supports_all, for_dep
|
|
||||||
|
|
||||||
for provider in self.get_all_that_provide(depend):
|
for provider in self.get_all_that_provide(depend):
|
||||||
found_in = self._get_supported_games(provider, visited)
|
found_in = self._get_supported_games(provider, visited)
|
||||||
if found_in is None:
|
if found_in is None:
|
||||||
@ -152,7 +145,6 @@ class GameSupport:
|
|||||||
else:
|
else:
|
||||||
for_dep.update(found_in)
|
for_dep.update(found_in)
|
||||||
|
|
||||||
self.dependency_cache[depend] = (dep_supports_all, for_dep)
|
|
||||||
return dep_supports_all, for_dep
|
return dep_supports_all, for_dep
|
||||||
|
|
||||||
def _get_supported_games_for_deps(self, package: GSPackage, visited: list[str]) -> Optional[set[str]]:
|
def _get_supported_games_for_deps(self, package: GSPackage, visited: list[str]) -> Optional[set[str]]:
|
||||||
@ -221,7 +213,6 @@ class GameSupport:
|
|||||||
return package.supported_games
|
return package.supported_games
|
||||||
|
|
||||||
def on_update(self, package: GSPackage, old_provides: Optional[set[str]] = None):
|
def on_update(self, package: GSPackage, old_provides: Optional[set[str]] = None):
|
||||||
self.dependency_cache = {}
|
|
||||||
to_update = {package}
|
to_update = {package}
|
||||||
checked = set()
|
checked = set()
|
||||||
|
|
||||||
@ -245,12 +236,10 @@ class GameSupport:
|
|||||||
checked.add(depending_package)
|
checked.add(depending_package)
|
||||||
|
|
||||||
def on_remove(self, package: GSPackage):
|
def on_remove(self, package: GSPackage):
|
||||||
self.dependency_cache = {}
|
|
||||||
del self.packages[package.id_]
|
del self.packages[package.id_]
|
||||||
self.on_update(package)
|
self.on_update(package)
|
||||||
|
|
||||||
def on_first_run(self):
|
def on_first_run(self):
|
||||||
self.dependency_cache = {}
|
|
||||||
for package in self.packages.values():
|
for package in self.packages.values():
|
||||||
if not package.is_confirmed:
|
if not package.is_confirmed:
|
||||||
self.on_update(package)
|
self.on_update(package)
|
||||||
|
@ -206,6 +206,8 @@ def test_cycle():
|
|||||||
assert support.all_errors == {
|
assert support.all_errors == {
|
||||||
"author/mod_b: Dependency cycle detected: author/mod_a -> author/mod_b -> author/mod_a",
|
"author/mod_b: Dependency cycle detected: author/mod_a -> author/mod_b -> author/mod_a",
|
||||||
"author/mod_a: Dependency cycle detected: author/mod_a -> author/mod_b -> author/mod_a",
|
"author/mod_a: Dependency cycle detected: author/mod_a -> author/mod_b -> author/mod_a",
|
||||||
|
"author/mod_b: Dependency cycle detected: author/mod_b -> author/mod_a -> author/mod_b",
|
||||||
|
"author/mod_a: Dependency cycle detected: author/mod_b -> author/mod_a -> author/mod_b",
|
||||||
"author/mod_b: Unable to fulfill dependency mod_a",
|
"author/mod_b: Unable to fulfill dependency mod_a",
|
||||||
"author/mod_a: Unable to fulfill dependency mod_b"
|
"author/mod_a: Unable to fulfill dependency mod_b"
|
||||||
}
|
}
|
||||||
@ -382,6 +384,8 @@ def test_update_cycle():
|
|||||||
assert support.all_errors == {
|
assert support.all_errors == {
|
||||||
"author/mod_c: Dependency cycle detected: author/mod_a -> author/mod_c -> author/mod_a",
|
"author/mod_c: Dependency cycle detected: author/mod_a -> author/mod_c -> author/mod_a",
|
||||||
"author/mod_a: Dependency cycle detected: author/mod_a -> author/mod_c -> author/mod_a",
|
"author/mod_a: Dependency cycle detected: author/mod_a -> author/mod_c -> author/mod_a",
|
||||||
|
"author/mod_c: Dependency cycle detected: author/mod_c -> author/mod_a -> author/mod_c",
|
||||||
|
"author/mod_a: Dependency cycle detected: author/mod_c -> author/mod_a -> author/mod_c",
|
||||||
"author/mod_a: Unable to fulfill dependency mod_c",
|
"author/mod_a: Unable to fulfill dependency mod_c",
|
||||||
"author/mod_c: Unable to fulfill dependency mod_a"
|
"author/mod_c: Unable to fulfill dependency mod_a"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user