mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-10-18 21:57:20 +02:00
* perf: bound request work and resource usage * fix: address performance review regressions * fix: guard content expiration and dashboard state * fix: tolerate cache outages and retire derived paths * fix: revalidate expiration claims and status pagination * fix: retry interrupted repository metadata cleanup * fix: retire obsolete content cache storage * fix: activate tree metadata and recheck expiration claims * fix: fence cache publication across expiration * fix: recover staged trees and enforce cache lifecycle cleanup * fix: prune expired transforms during database outages * fix: finish conference removals and reload expiration candidates
18 lines
894 B
TypeScript
18 lines
894 B
TypeScript
import { Archiver, EntryData } from "archiver";
|
|
import { Readable } from "stream";
|
|
/** 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) => {
|
|
const cleanup = () => {
|
|
archive.removeListener("entry", done); archive.removeListener("error", fail);
|
|
archive.removeListener("close", closed); source.removeListener("error", fail);
|
|
};
|
|
const done = () => { cleanup(); resolve(); };
|
|
const fail = (error: Error) => { cleanup(); source.destroy(); reject(error); };
|
|
const closed = () => fail(new Error("archive_cancelled"));
|
|
archive.once("entry", done); archive.once("error", fail); archive.once("close", closed);
|
|
source.once("error", fail);
|
|
archive.append(source, options);
|
|
});
|
|
}
|