UNPKG

@pgxsinkit/pgwasm

Version:
39 lines • 2.26 kB
/** * A minimal ustar codec: regular files and directories, which is everything a Postgres data * directory and an npm tarball hold. * * Writing produces the layout pgwasm's Store backups have always had: a 512-byte ustar header per * entry, the name in the `name` field when it fits (99 bytes), the payload padded to a record, and * two zero records at the end. Reading also accepts what other writers add around that: a name * split into `prefix` + `name`, PAX extended headers (`x`, per entry; `g`, global and ignored) and GNU * long names (`L`). Links, devices and FIFOs are refused rather than skipped, so an archive with * content this codec cannot represent fails loudly instead of restoring partially. * * Reading is strict about completeness, for the same reason: a data directory restored from part of * a backup is a corrupt database. A header or payload cut short, a size that is not a number, a * header whose checksum fails and an archive without its two zero end records are all refused. The * end records are required because every writer whose archives reach this reader writes them: every * PGlite Store backup came from tinytar's `tar()`, which always appends them (checked for the fork's * dumps and the prepopulated data directory), as do npm's tarballs and the extension bundles. */ /** One archive member. */ export interface TarEntry { /** The member's path as stored, `/`-separated. */ readonly name: string; readonly type: "file" | "directory"; /** Permission bits (the `0o7777` part of the mode). */ readonly mode: number; /** Modification time, whole seconds since the epoch. */ readonly mtimeSeconds: number; /** The file's bytes; empty for a directory. */ readonly data: Uint8Array; } /** An archive this codec cannot read or represent. */ export declare class TarFormatError extends Error { readonly name = "TarFormatError"; } /** Serialize entries into an uncompressed ustar archive. */ export declare function writeTar(entries: readonly TarEntry[]): Uint8Array; /** Parse an uncompressed ustar archive. Throws {@link TarFormatError} for anything it cannot represent. */ export declare function readTar(archive: Uint8Array): TarEntry[]; //# sourceMappingURL=tar.d.ts.map