The media chain moves to novox/mesh-media-catalog; home-assistant and searxng keep their parts of that stack
jackett leaves: it is registered from novox/mesh-media-catalog with sonarr, radarr, lidarr, bazarr, nzbget, qbittorrent, bookshelf, plex, tautulli, kometa and ombi (PRs 145-168 consolidated there). What those branches changed outside the chain stays here: home-assistant's provisions (sonarr-api, radarr-api, mqtt-topic — from #147) and searxng's sidecar dialling the port it was given (#154).
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// What the mesh delivered to home-assistant's provisions step, and the step's own small memory.
|
||||
//
|
||||
// Per provision it requires, the mesh writes two files beside each other (the manifest's `binds` and
|
||||
// `secrets`): `<provision>.json`, the binding — where the provider is (`at`), what it serves (`port`,
|
||||
// `scheme`, …) and the login this module presents (`as`) — and `<provision>.secret`, the pair
|
||||
// credential. Nothing here guesses a host, a port or a key.
|
||||
|
||||
import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
|
||||
import type { Binding, Marks } from "./connections.js";
|
||||
|
||||
/** A file the mesh wrote, or undefined when it is not there. */
|
||||
export async function readIfThere(path: string | undefined): Promise<string | undefined> {
|
||||
if (!path) return undefined;
|
||||
return readFile(path, "utf8").catch(() => undefined);
|
||||
}
|
||||
|
||||
/** A binding file parsed, or undefined when absent or not JSON. */
|
||||
export async function readBinding(path: string): Promise<Binding | undefined> {
|
||||
const raw = await readIfThere(path);
|
||||
if (raw === undefined) return undefined;
|
||||
try {
|
||||
return JSON.parse(raw) as Binding;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
export function marksIn(dir: string): Marks {
|
||||
return {
|
||||
async get(name) {
|
||||
return (await readIfThere(join(dir, `${name}.digest`)))?.trim() || undefined;
|
||||
},
|
||||
async set(name, value) {
|
||||
await mkdir(dir, { recursive: true, mode: 0o700 });
|
||||
const path = join(dir, `${name}.digest`);
|
||||
await writeFile(`${path}.tmp`, `${value}\n`, { mode: 0o600 });
|
||||
await rename(`${path}.tmp`, path);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user