refreshMounts

tcmts.registry.refreshMounts · #vzo6a5e7 · term · runs on the server

uses tcmts.registry.releases, which uses tcmts.server.table, which uses tcmts.server.Table, which uses #tcm/host (database)

Read the registry's mounts again (registryMounts): as a page of its code is asked for.

import {
  codebaseHref, codebases, everyone, libraryHref, registryMounts, releases, said,
} from "#codebase/tcmts/registry";

export async function refreshMounts(): Promise<void> {
  const who = await everyone();
  const next = new Map<string, { label: string; href: string; tab: string }>();
  for (const { value: r } of await releases.find())
    if (r.mount && r.state !== "failed") {
      const w = who.get(r.did) ?? { did: r.did };
      next.set(r.mount, {
        label: `${said(w)}/${r.package} ${r.version}`,
        href: libraryHref(w, r.package, r.version),
        tab: "libraries",
      });
    }
  for (const { value: c } of await codebases.find({ state: "verified" }))
    if (c.mount) {
      const w = who.get(c.did) ?? { did: c.did };
      next.set(c.mount, {
        label: `${said(w)}/${c.name}`,
        href: codebaseHref(w, c.name, "code"),
        tab: "codebases",
      });
    }
  registryMounts.clear();
  for (const [k, v] of next) registryMounts.set(k, v);
}

uses

used by