mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-22 15:28:29 +02:00
fix: handle production source failures and reduce ZIP work
This commit is contained in:
1 parent
bd7d6f0bef
commit
705f7c428a
16 files changed
+612
-86
No files matched your search
@@ -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) => {
|
||||
|
||||
Reference in new issue
Block a user