Skip to content

⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.

fix: support using monolith content for other archives

Spy7d45249e8fce
diff --git a/apps/worker/lib/archiveHandler.ts b/apps/worker/lib/archiveHandler.ts
index 707454f8..7e6a4548 100644
--- a/apps/worker/lib/archiveHandler.ts
+++ b/apps/worker/lib/archiveHandler.ts
@@ -3,7 +3,7 @@ import { prisma } from "@linkwarden/prisma";
import sendToWayback from "./preservationScheme/sendToWayback";
import { AiTaggingMethod } from "@linkwarden/prisma/client";
import fetchHeaders from "./fetchHeaders";
-import { createFolder, removeFiles } from "@linkwarden/filesystem";
+import { createFolder, readFile, removeFiles } from "@linkwarden/filesystem";
import handleMonolith from "./preservationScheme/handleMonolith";
import handleReadability from "./preservationScheme/handleReadability";
import handleArchivePreview from "./preservationScheme/handleArchivePreview";
@@ -119,6 +119,22 @@ export default async function archiveHandler(
} else if (link.url) {
await page.goto(link.url, { waitUntil: "domcontentloaded" });
+ // Handle Monolith being sent in beforehand while making sure other values line up
+ if (link.monolith) {
+ // Use Monolith content instead of page
+ const file = await readFile(link.monolith);
+
+ if (file.contentType == "text/html") {
+ const fileContent = file.file;
+
+ if (typeof fileContent === "string") {
+ await page.setContent(fileContent, { waitUntil: "domcontentloaded" });
+ } else {
+ await page.setContent(fileContent.toString("utf-8"), { waitUntil: "domcontentloaded" });
+ }
+ }
+ }
+
const metaDescription = await page.evaluate(() => {
const description = document.querySelector(
'meta[name="description"]'