mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-08 22:17:34 +01:00
Prefetches dependencies of likely dependency candidates
This commit is contained in:
parent
4238dbd412
commit
75c118c483
@ -59,7 +59,7 @@ def edit_package(token, package):
|
|||||||
return api_edit_package(token, package, request.json)
|
return api_edit_package(token, package, request.json)
|
||||||
|
|
||||||
|
|
||||||
def resolve_package_deps(out, package, only_hard):
|
def resolve_package_deps(out, package, only_hard, depth=1):
|
||||||
id = package.getId()
|
id = package.getId()
|
||||||
if id in out:
|
if id in out:
|
||||||
return
|
return
|
||||||
@ -67,6 +67,9 @@ def resolve_package_deps(out, package, only_hard):
|
|||||||
ret = []
|
ret = []
|
||||||
out[id] = ret
|
out[id] = ret
|
||||||
|
|
||||||
|
if package.type != PackageType.MOD:
|
||||||
|
return
|
||||||
|
|
||||||
for dep in package.dependencies:
|
for dep in package.dependencies:
|
||||||
if only_hard and dep.optional:
|
if only_hard and dep.optional:
|
||||||
continue
|
continue
|
||||||
@ -74,12 +77,16 @@ def resolve_package_deps(out, package, only_hard):
|
|||||||
if dep.package:
|
if dep.package:
|
||||||
name = dep.package.name
|
name = dep.package.name
|
||||||
fulfilled_by = [ dep.package.getId() ]
|
fulfilled_by = [ dep.package.getId() ]
|
||||||
resolve_package_deps(out, dep.package, only_hard)
|
resolve_package_deps(out, dep.package, only_hard, depth)
|
||||||
|
|
||||||
elif dep.meta_package:
|
elif dep.meta_package:
|
||||||
name = dep.meta_package.name
|
name = dep.meta_package.name
|
||||||
fulfilled_by = [ pkg.getId() for pkg in dep.meta_package.packages]
|
fulfilled_by = [ pkg.getId() for pkg in dep.meta_package.packages]
|
||||||
# TODO: resolve most likely candidate
|
|
||||||
|
if depth == 1:
|
||||||
|
most_likely = next((pkg for pkg in dep.meta_package.packages if pkg.type == PackageType.MOD), None)
|
||||||
|
if most_likely:
|
||||||
|
resolve_package_deps(out, most_likely, only_hard, depth + 1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise Exception("Malformed dependency")
|
raise Exception("Malformed dependency")
|
||||||
|
Loading…
Reference in New Issue
Block a user