use monolith instead of singlefile
This commit is contained in:
@@ -102,7 +102,7 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
|
||||
readable: !link.readable?.startsWith("archive")
|
||||
? "pending"
|
||||
: undefined,
|
||||
singlefile: !link.singlefile?.startsWith("archive")
|
||||
monolith: !link.monolith?.startsWith("archive")
|
||||
? "pending"
|
||||
: undefined,
|
||||
preview: !link.readable?.startsWith("archive")
|
||||
@@ -151,11 +151,11 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
|
||||
)
|
||||
await handleScreenshotAndPdf(link, page, user);
|
||||
|
||||
// SingleFile
|
||||
// Monolith
|
||||
if (
|
||||
!link.singlefile?.startsWith("archive") &&
|
||||
!link.singlefile?.startsWith("unavailable") &&
|
||||
user.archiveAsSinglefile &&
|
||||
!link.monolith?.startsWith("archive") &&
|
||||
!link.monolith?.startsWith("unavailable") &&
|
||||
user.archiveAsMonolith &&
|
||||
link.url
|
||||
)
|
||||
await handleMonolith(link, content);
|
||||
@@ -183,7 +183,7 @@ export default async function archiveHandler(link: LinksAndCollectionAndOwner) {
|
||||
image: !finalLink.image?.startsWith("archives")
|
||||
? "unavailable"
|
||||
: undefined,
|
||||
singlefile: !finalLink.singlefile?.startsWith("archives")
|
||||
monolith: !finalLink.monolith?.startsWith("archives")
|
||||
? "unavailable"
|
||||
: undefined,
|
||||
pdf: !finalLink.pdf?.startsWith("archives")
|
||||
|
||||
@@ -75,7 +75,7 @@ export default async function getPublicUser(
|
||||
username: lessSensitiveInfo.username,
|
||||
image: lessSensitiveInfo.image,
|
||||
archiveAsScreenshot: lessSensitiveInfo.archiveAsScreenshot,
|
||||
archiveAsSinglefile: lessSensitiveInfo.archiveAsSinglefile,
|
||||
archiveAsMonolith: lessSensitiveInfo.archiveAsMonolith,
|
||||
archiveAsPDF: lessSensitiveInfo.archiveAsPDF,
|
||||
};
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ export default async function updateUserById(
|
||||
),
|
||||
locale: i18n.locales.includes(data.locale) ? data.locale : "en",
|
||||
archiveAsScreenshot: data.archiveAsScreenshot,
|
||||
archiveAsSinglefile: data.archiveAsSinglefile,
|
||||
archiveAsMonolith: data.archiveAsMonolith,
|
||||
archiveAsPDF: data.archiveAsPDF,
|
||||
archiveAsWaybackMachine: data.archiveAsWaybackMachine,
|
||||
linksRouteTo: data.linksRouteTo,
|
||||
|
||||
@@ -19,7 +19,7 @@ const handleMonolith = async (link: Link, content: string) => {
|
||||
);
|
||||
|
||||
if (!html?.length) {
|
||||
console.error("Error running SINGLEFILE_ARCHIVE_COMMAND: Empty buffer");
|
||||
console.error("Error running MONOLITH: Empty buffer");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,12 +30,12 @@ const handleMonolith = async (link: Link, content: string) => {
|
||||
await prisma.link.update({
|
||||
where: { id: link.id },
|
||||
data: {
|
||||
singlefile: `archives/${link.collectionId}/${link.id}.html`,
|
||||
monolith: `archives/${link.collectionId}/${link.id}.html`,
|
||||
},
|
||||
});
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("Error running SINGLEFILE_ARCHIVE_COMMAND:", err);
|
||||
console.error("Error running MONOLITH:", err);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
pdfAvailable,
|
||||
readabilityAvailable,
|
||||
screenshotAvailable,
|
||||
singlefileAvailable,
|
||||
monolithAvailable,
|
||||
} from "../shared/getArchiveValidity";
|
||||
|
||||
export const generateLinkHref = (
|
||||
@@ -39,10 +39,10 @@ export const generateLinkHref = (
|
||||
return `/preserved/${link?.id}?format=${
|
||||
link?.image?.endsWith("png") ? ArchivedFormat.png : ArchivedFormat.jpeg
|
||||
}`;
|
||||
} else if (account.linksRouteTo === LinksRouteTo.SINGLEFILE) {
|
||||
if (!singlefileAvailable(link)) return link.url || "";
|
||||
} else if (account.linksRouteTo === LinksRouteTo.MONOLITH) {
|
||||
if (!monolithAvailable(link)) return link.url || "";
|
||||
|
||||
return `/preserved/${link?.id}?format=${ArchivedFormat.singlefile}`;
|
||||
return `/preserved/${link?.id}?format=${ArchivedFormat.monolith}`;
|
||||
} else {
|
||||
return link.url || "";
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ export function readabilityAvailable(
|
||||
);
|
||||
}
|
||||
|
||||
export function singlefileAvailable(
|
||||
export function monolithAvailable(
|
||||
link: LinkIncludingShortenedCollectionAndTags
|
||||
) {
|
||||
return (
|
||||
link &&
|
||||
link.singlefile &&
|
||||
link.singlefile !== "pending" &&
|
||||
link.singlefile !== "unavailable"
|
||||
link.monolith &&
|
||||
link.monolith !== "pending" &&
|
||||
link.monolith !== "unavailable"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user