From 2ee8f5f28db288fcc14dc2c5771959983cbf4220 Mon Sep 17 00:00:00 2001 From: taoky Date: Mon, 27 Nov 2023 17:08:53 +0800 Subject: [PATCH] lug: another try of mirrorz adhoc support --- config.siyuan.yaml | 1 + lug/worker-script/mirrorz.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config.siyuan.yaml b/config.siyuan.yaml index 5378d60c..c7eb17f5 100644 --- a/config.siyuan.yaml +++ b/config.siyuan.yaml @@ -419,6 +419,7 @@ repos: serve_mode: mirror_intel interval: 10800 name: homebrew-bottles + z_url: "/homebrew-bottles/bottles" <<: *oneshot_common # rust-static - type: shell_script diff --git a/lug/worker-script/mirrorz.py b/lug/worker-script/mirrorz.py index a6e53494..4b7a6f92 100755 --- a/lug/worker-script/mirrorz.py +++ b/lug/worker-script/mirrorz.py @@ -66,7 +66,7 @@ def mirror_item(worker, param, help_items, sources): } return mirror -def link_to(lug, summary, mirrors, help_items, sources): +def z_adhocs(lug, summary, mirrors, help_items, sources): for item in lug["repos"]: if "z_link_to" in item: for worker, param in summary["WorkerStatus"].items(): @@ -74,6 +74,10 @@ def link_to(lug, summary, mirrors, help_items, sources): # use item name instead of worker, still use worker param mirror = mirror_item(item["name"], param, help_items, sources) mirrors.append(mirror) + if "z_url" in item: + for mirror in mirrors: + if mirror["cname"] == name(item["name"]): + mirror["url"] = item["z_url"] def main(): global options @@ -92,13 +96,17 @@ def main(): mirrorz["info"] = [] mirrors = [] sources = {item["name"]: item.get("source", "") for item in lug["repos"]} + adhoc = lug.get("mirrorz_adhoc", {}) for worker, param in summary["WorkerStatus"].items(): if worker.startswith(".") or worker == 'sjtug-internal' or worker == 'test': continue mirror = mirror_item(worker, param, help_items, sources) + if worker in adhoc: + for key, value in adhoc[worker].items(): + mirror[key] = value mirrors.append(mirror) - link_to(lug, summary, mirrors, help_items, sources) + z_adhocs(lug, summary, mirrors, help_items, sources) mirrorz["mirrors"] = mirrors mirrorz["extension"] = "D"