From f96a9407d57cf653c6fcada5f87ceeae75b202a8 Mon Sep 17 00:00:00 2001 From: bes-r Date: Sat, 30 May 2026 00:55:16 +0200 Subject: [PATCH] fix: voorkom duplicate repo-IDs bij toevoegen via UI --- server-up/app.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/server-up/app.py b/server-up/app.py index e2a1f2e..6765cf3 100644 --- a/server-up/app.py +++ b/server-up/app.py @@ -316,7 +316,13 @@ def api_repos_add(): if not url: return jsonify(ok=False, msg="URL vereist") repos = list(cfg.load().get("APP_REPOS", [])) - rid = d.get("id", url.split("/")[-1].replace(".git", "")).strip()[:30] or str(int(time.time())) + existing_ids = {r["id"] for r in repos} + base_rid = d.get("id", url.split("/")[-1].replace(".git", "")).strip()[:30] or str(int(time.time())) + rid = base_rid + counter = 1 + while rid in existing_ids: + rid = f"{base_rid}-{counter}" + counter += 1 repos.append({"id": rid, "name": d.get("name", "").strip() or url.split("/")[-1], "url": url, "branch": d.get("branch", "main"), "token": d.get("token", ""), "subdir": d.get("subdir", "")}) @@ -877,8 +883,14 @@ def api_modrepos_add(): if not url: return jsonify(ok=False, msg="URL vereist") repos = list(cfg.load().get("MODULE_REPOS", [])) - repos.append({"id": d.get("id", url.split("/")[-1].replace(".git", ""))[:30], - "name": d.get("name", "") or url.split("/")[-1], + existing_ids = {r["id"] for r in repos} + base_rid = d.get("id", url.split("/")[-1].replace(".git", ""))[:30] + rid = base_rid + counter = 1 + while rid in existing_ids: + rid = f"{base_rid}-{counter}" + counter += 1 + repos.append({"id": rid, "name": d.get("name", "") or url.split("/")[-1], "url": url, "branch": d.get("branch", "main"), "subdir": d.get("subdir", "")}) cfg.patch({"MODULE_REPOS": repos})