From f813b9c7cef18191915ed92fb4564d8faeda0175 Mon Sep 17 00:00:00 2001 From: clover caruso Date: Mon, 6 Oct 2025 01:37:24 -0700 Subject: [PATCH] fix(site): deployment must download databases see https://paperclover.net/q+a#2510051828 --- src/deploy.ts | 38 +++++++++++++++++++++++------------- src/file-viewer/bin/scan3.ts | 15 ++++++++++++-- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/src/deploy.ts b/src/deploy.ts index 15bb02b59370263c504d57ed235d320ecfbb7b98..a0182e53766f1a927d5a09ad1337e6c7c24f2488 100644 --- a/src/deploy.ts +++ b/src/deploy.ts @@ -1,5 +1,28 @@ export async function main() { - if (!process.argv.includes("-f")) await incr.restore(); + await rsync.spawn({ + cwd: Path.resolve(import.meta.dirname).parent!.toString(), + args: [ + "-a", + "--progress", + "clo@zenith:/mnt/storage1/clover/Documents/Config/paperclover/cache.sqlite", + ".clover/", + ], + progress: progress.start("download file cache"), + }); + await rsync.spawn({ + cwd: Path.resolve(import.meta.dirname).parent!.toString(), + args: [ + "-a", + "--progress", + "clo@paperclover.net:~/paperclover.net/.clover/questions.sqlite", + ".clover/", + ], + progress: progress.start("download questions state"), + }); + + // cannot call incr.restore until database calls are + // considered in the watch graph. + // await incr.restore() await incr.compile(generate); await rsync.spawn({ @@ -18,19 +41,6 @@ export async function main() { ], progress: progress.start("copy site files"), }); - const cache = Path.resolve(".clover/cache.sqlite").ifExistsSync(); - if (cache) { - await rsync.spawn({ - cwd: Path.resolve(import.meta.dirname).parent!.toString(), - args: [ - "-a", - "--progress", - cache.toString(), - "paperclover.net:~/paperclover.net/.clover/cache.sqlite", - ], - progress: progress.start("copy file viewer cache"), - }); - } await subprocess.spawnAndWait({ stdio: "inherit", cmd: [ diff --git a/src/file-viewer/bin/scan3.ts b/src/file-viewer/bin/scan3.ts index b44982cb9e69371040d062d051bcbb3150e90ae1..762c402ab2464fac0bf4322f3906576db420a4d4 100644 --- a/src/file-viewer/bin/scan3.ts +++ b/src/file-viewer/bin/scan3.ts @@ -372,9 +372,19 @@ export async function main() { MediaFile.db.file, "clo@zenith:/mnt/storage1/clover/Documents/Config/paperclover/cache.sqlite", ], - progress: progress.start("Uploading database"), + progress: progress.start("Uploading database (source of truth)"), 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/", + ], + progress: progress.start("Uploading database (web node)"), + }); if (sotToken) { const res = await fetch("https://db.paperclover.net/reload", { method: "POST", @@ -388,6 +398,7 @@ 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" + @@ -1012,4 +1023,4 @@ import * as derived from "@/file-viewer/models/derived.ts"; import * as transcodeRules from "@/file-viewer/transcode-rules.ts"; import { rawFileRoot as root } from "../paths.ts"; -import { UNWRAP } from "lib/assert.ts"; +import { ASSERT, UNWRAP } from "lib/assert.ts"; -- 2.54.0