Skip to content

Commit 96891d5

Browse files
committed
Make module linking more robust if re-run in an already prepared environment
1 parent 2a4318b commit 96891d5

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/doblib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "0.19.5"
1+
VERSION = "0.19.6"

src/doblib/base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,7 @@
1515
"BOOTSTRAP_MODE": (SECTION, "mode"),
1616
"BOOTSTRAP_DEBUGGER": (SECTION, "debugger"),
1717
}
18+
19+
20+
class DuplicateModule(Exception):
21+
pass

src/doblib/env.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ def _link_modules(self):
186186
os.makedirs(base.ADDON_PATH, exist_ok=True)
187187
utils.info("Linking Odoo modules")
188188

189+
linked_modules = set()
189190
for repo_src, repo in self.get("repos", default={}).items():
190191
target = os.path.abspath(repo.get("addon_path", repo_src))
191192
modules = repo.get("modules", [])
@@ -194,12 +195,23 @@ def _link_modules(self):
194195

195196
for module in os.listdir(target):
196197
path = os.path.join(target, module)
198+
link_path = os.path.join(base.ADDON_PATH, module)
197199
# Check if module
198200
if not os.path.isfile(os.path.join(path, "__manifest__.py")):
199201
continue
200202

201-
if utils.check_filters(module, whitelist, blacklist):
202-
os.symlink(path, os.path.join(base.ADDON_PATH, module))
203+
# Apply whitelist and blacklist
204+
if not utils.check_filters(module, whitelist, blacklist):
205+
continue
206+
207+
# Keep the duplication check to point out setup problems
208+
if module in linked_modules:
209+
raise base.DuplicateModule(f"Duplicate module {module!r} found")
210+
211+
linked_modules.add(module)
212+
213+
if not os.path.islink(path):
214+
os.symlink(path, link_path)
203215

204216
def _init_odoo(self):
205217
"""Initialize Odoo to enable the module import"""

0 commit comments

Comments
 (0)