Release Archive Tools 0.2.0
Verify / verify (push) Canceled after 0s

This commit is contained in:
2026-09-02 09:34:59 +02:00
parent a49ec6b17a
commit fe578f46bd
47 changed files with 3337 additions and 253 deletions
+6 -11
View File
@@ -1,3 +1,4 @@
import { formatBytes } from "@add-ideas/toolbox-helpers";
import { ArchivePolicyError } from "./errors";
export const ARCHIVE_LIMITS = Object.freeze({
@@ -18,6 +19,10 @@ export const ARCHIVE_LIMITS = Object.freeze({
maxCreateFiles: 5_000,
maxCreateBytes: 512 * 1024 * 1024,
maxPaxHeaderBytes: 1024 * 1024,
maxGzipMembers: 256,
maxPasswordBytes: 1_024,
maxStructuralHeaderBytes: 16 * 1024 * 1024,
maxArchiveHeaderBlocks: 40_000,
});
export function assertFiniteSafeInteger(value: number, label: string): void {
@@ -38,17 +43,7 @@ export function assertSourceSize(file: Blob): void {
}
}
export function formatBytes(bytes: number): string {
if (!Number.isFinite(bytes)) return "unknown";
const units = ["B", "KiB", "MiB", "GiB"];
let value = Math.max(0, bytes);
let unit = 0;
while (value >= 1024 && unit < units.length - 1) {
value /= 1024;
unit += 1;
}
return `${value >= 10 || unit === 0 ? value.toFixed(0) : value.toFixed(1)} ${units[unit]}`;
}
export { formatBytes };
export function throwIfAborted(signal?: AbortSignal): void {
if (signal?.aborted) {