fix: handle production source failures and reduce ZIP work

This commit is contained in:
Thomas Durieux committed 2026-10-09 09:40:54 +00:00
1 parent bd7d6f0bef
commit 705f7c428a
16 files changed
+612 -86

No files matched your search

+13 -1
View File
@@ -1,5 +1,17 @@
import { Archiver, EntryData } from "archiver";
import { Archiver, EntryData, ZipEntryData } from "archiver";
import { extname } from "path";
import { Readable } from "stream";
const compressedExtensions = new Set([
".png", ".jpg", ".jpeg", ".gif", ".webp", ".avif", ".heif", ".heic",
".mp4", ".m4v", ".mov", ".webm", ".mp3", ".m4a", ".aac", ".ogg", ".flac",
".zip", ".gz", ".tgz", ".bz2", ".xz", ".7z", ".rar", ".zst", ".woff", ".woff2",
]);
/** Store already compressed assets; every entry still passes through anonymization. */
export function zipEntryOptions(name: string, originalName = name): ZipEntryData {
return { name, store: compressedExtensions.has(extname(originalName).toLowerCase()) };
}
/** Allow only one active entry; compression and the response provide backpressure. */
export function appendArchiveEntry(archive: Archiver, source: Readable, options: EntryData): Promise<void> {
return new Promise((resolve, reject) => {