Merge pull request #24688 from frappe/revert-24605-revert-24511-module-map-only-site-apps
Revert "Revert "fix(module_map): only include apps installed on the site - not everything on the bench""
This commit is contained in:
commit
8ac7293e91
1 changed files with 12 additions and 3 deletions
|
|
@ -25,6 +25,7 @@ from typing import TYPE_CHECKING, Any, Literal, Optional, TypeAlias, overload
|
|||
import click
|
||||
from werkzeug.local import Local, release_local
|
||||
|
||||
import frappe
|
||||
from frappe.query_builder import (
|
||||
get_query,
|
||||
get_query_builder,
|
||||
|
|
@ -298,7 +299,7 @@ def init(site: str, sites_path: str = ".", new_site: bool = False, force=False)
|
|||
local.qb = get_query_builder(local.conf.db_type)
|
||||
local.qb.get_query = get_query
|
||||
setup_redis_cache_connection()
|
||||
setup_module_map()
|
||||
setup_module_map(include_all_apps=not (frappe.request or frappe.job or frappe.flags.in_migrate))
|
||||
|
||||
if not _qb_patched.get(local.conf.db_type):
|
||||
patch_query_execute()
|
||||
|
|
@ -1684,7 +1685,7 @@ def append_hook(target, key, value):
|
|||
target[key].extend(value)
|
||||
|
||||
|
||||
def setup_module_map():
|
||||
def setup_module_map(include_all_apps=True):
|
||||
"""Rebuild map of all modules (internal)."""
|
||||
if conf.db_name:
|
||||
local.app_modules = cache.get_value("app_modules")
|
||||
|
|
@ -1692,10 +1693,18 @@ def setup_module_map():
|
|||
|
||||
if not (local.app_modules and local.module_app):
|
||||
local.module_app, local.app_modules = {}, {}
|
||||
for app in get_all_apps(with_internal_apps=True):
|
||||
if include_all_apps:
|
||||
apps = get_all_apps(with_internal_apps=True)
|
||||
else:
|
||||
apps = get_installed_apps(_ensure_on_bench=True)
|
||||
for app in apps:
|
||||
local.app_modules.setdefault(app, [])
|
||||
for module in get_module_list(app):
|
||||
module = scrub(module)
|
||||
if module in local.module_app:
|
||||
print(
|
||||
f"WARNING: module `{module}` found in apps `{local.module_app[module]}` and `{app}`"
|
||||
)
|
||||
local.module_app[module] = app
|
||||
local.app_modules[app].append(module)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue