From 10eaddedc5136acd4d7f8ac8276c4c8e90905703 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Mon, 6 Oct 2025 21:45:15 -0700 Subject: [PATCH] fix(site): revive scan3 after breaking it in the lib patches --- framework/font.ts | 8 ++++++-- lib/log/stack.ts | 13 +++++++++---- src/file-viewer/bin/scan3.ts | 10 +++------- src/file-viewer/models/derived.ts | 2 +- src/file-viewer/rsync.ts | 2 +- 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/framework/font.ts b/framework/font.ts index e886a96b9ada4301e54a1fdf78fd223b72759b12..07ff47ff7143e98e9bebe3f23f1d38f9b1bcd840 100644 --- a/framework/font.ts +++ b/framework/font.ts @@ -19,7 +19,10 @@ export async function buildFonts(p: progress.Ref, fonts: sg.Font[]) { ]); } - const instances = new async.OnceMap(); + const instances = new async.OnceMap( + (_: string, x: () => Promise) => x(), + (x) => x[0], + ); function getArgs(vars: sg.FontVars) { return Object.entries(vars).map((x) => { const lower = x[0].toLowerCase(); @@ -42,7 +45,7 @@ export async function buildFonts(p: progress.Ref, fonts: sg.Font[]) { const args = getArgs(vars); const hash = getHash(input, args); const outfile = path.join(temp, `${hash}${path.extname(input)}`); - await instances.get(outfile, async () => { + await instances.getOrRun(outfile, async () => { await fs.rm(outfile, { force: true }); await subprocess.exec(path.join(bin, "fonttools"), [ "varLib.instancer", @@ -212,3 +215,4 @@ import * as crypto from "node:crypto"; import * as async from "lib/async.ts"; import * as error from "lib/error.ts"; import * as progress from "../lib/log/progress.ts"; +import { ASSERT } from "lib/assert.ts"; diff --git a/lib/log/stack.ts b/lib/log/stack.ts index bf2e4f6ac867be55cc978d3ece4a498a18fa0d9c..e92f3273add9e50e48e60e9f7ef6498002b9b865 100644 --- a/lib/log/stack.ts +++ b/lib/log/stack.ts @@ -88,11 +88,11 @@ export function capture(trimStart = 2): Frame[] { export function format(error: Error, colors = false): string { const { name, message, stack: _, ...payload } = error; - const headingLine = (colors ? ansi.fgRed : "") + + let out = (colors ? ansi.fgRed : "") + (name && name !== "Error" ? `[${name}] ` : "") + message + (colors ? ansi.fgReset : "") + "\n"; - const payloadLines = Object.entries(payload) + out += Object.entries(payload) .map(([k, v]) => " " + k + (colors ? ansi.style(ansi.dim, ":") : ":") + @@ -111,11 +111,16 @@ export function format(error: Error, colors = false): string { ].includes(frame.fn ?? "") ); } + if (error instanceof AggregateError) { + for (const err of error.errors) { + out += format(err, true); + } + } if (frames.length) { - frameLines = frames.map((frame) => formatFrame(frame, colors)).join("\n"); + out += frames.map((frame) => formatFrame(frame, colors)).join("\n"); } - return headingLine + payloadLines + frameLines + "\n"; + return out + "\n"; } /** format a single stack trace frame. see `format` for more details. */ diff --git a/src/file-viewer/bin/scan3.ts b/src/file-viewer/bin/scan3.ts index 762c402ab2464fac0bf4322f3906576db420a4d4..469b703f816ca68389ec7e59aa239f75c6f53682 100644 --- a/src/file-viewer/bin/scan3.ts +++ b/src/file-viewer/bin/scan3.ts @@ -376,12 +376,9 @@ export async function main() { cwd: process.cwd(), }); await rsync.spawn({ - cwd: Path.resolve(import.meta.dirname).parent!.toString(), args: [ - "-a", - "--progress", - "clo@paperclover.net:~/paperclover.net/.clover/questions.sqlite", - ".clover/", + MediaFile.db.file, + "clo@paperclover.net:paperclover.net/.clover/cache.sqlite", ], progress: progress.start("Uploading database (web node)"), }); @@ -398,7 +395,6 @@ export async function main() { ); } } else console.warn("Missing SOT token"); - // TODO: signal to web node(s) console.info( "Updated file viewer index in \x1b[1m" + @@ -601,7 +597,7 @@ const procImageSubsets: Process = { }, }; -const videoArgsCache = new async.OnceMap2(transcodeRules.getVideoInputArgs); +const videoArgsCache = new async.OnceMap(transcodeRules.getVideoInputArgs); const qualityMap: Record = { u: "ultra-high", diff --git a/src/file-viewer/models/derived.ts b/src/file-viewer/models/derived.ts index 6c3194a7722fb33239897a2352bb0c86113c3da3..6ed3f1f78bba31af11fcb3c852c6ed7f59acb1a1 100644 --- a/src/file-viewer/models/derived.ts +++ b/src/file-viewer/models/derived.ts @@ -201,4 +201,4 @@ import * as fs from "node:fs"; import * as crypto from "node:crypto"; import * as queue from "lib/queue.ts"; import * as progress from "lib/log/progress.ts"; -import { derivedFileRoot } from "../paths.ts"; +import { ASSERT } from "lib/assert.ts"; diff --git a/src/file-viewer/rsync.ts b/src/file-viewer/rsync.ts index a0ea9bf7ebd38e7e8e75ab5044bf967b61bf3006..d6cafa002d5038e53cd6421330afbcd4008f2ff9 100644 --- a/src/file-viewer/rsync.ts +++ b/src/file-viewer/rsync.ts @@ -75,7 +75,7 @@ export async function spawn(options: SpawnOptions) { ? `${currentFile.slice(0, 3)}..${currentFile.slice(-15)}` : currentFile; node.text = `${title} - ${fileName}${ - extras.length > 0 ? `( ${extras})` : "" + extras.length > 0 ? ` (${extras})` : "" }`; } else result satisfies never; }; -- 2.54.0