LOCAL_CAPABILITIESconstconst LOCAL_CAPABILITIES: readonly ["read", "write", "list", "stat", "delete", "cas", "rename"]The capabilities of the store in a folder.
The store in a folder of the local file system. A path of the store is a file below the folder; a folder of the file system is never an object. Its revision is sha256: and the digest of the bytes, so a revision means the same as in memory; a write goes whole through a temporary file in the folder of the file and a rename, under a lock taken for the path, so a reader sees the old bytes or the new and two writers that expect the same revision cannot both win. It refuses a path another file system could not hold and every operation that would reach a file outside its folder, by a path or by a link; it never lists the files it makes itself (.anyfs- names). It has no batch: the file system has no atomic change of several files, and a store does not claim what it cannot keep.
Limits, said once: the check that a path stays inside the folder and the use of the path are two steps, so a link made between them by another process is not caught; the revision of a file is the digest of its bytes, so stat and list read what they describe (a digest is kept for a file whose size and time have not changed in two seconds); nothing is flushed to the disk before a rename.
import { localStore } from "./mod.ts";
const store = await localStore("/var/lib/fleet", { create: true });
store.kind === "ok" && store.value.consistency; // "strong"LOCAL_CAPABILITIESconstconst LOCAL_CAPABILITIES: readonly ["read", "write", "list", "stat", "delete", "cas", "rename"]The capabilities of the store in a folder.
LocalStoretypeno test imports ittype LocalStore = Store<(typeof LOCAL_CAPABILITIES)[number]>;The type of the store in a folder.
LocalOptionstypeno test imports ittype LocalOptions = { readonly create?: boolean; readonly portable?: boolean; readonly lockTimeoutMs?: number; readonly caseSensitive?: boolean; readonly lockDir?: string };What the store in a folder is made with: whether to make the folder, whether to refuse paths another file system could not hold (the default), how long to wait for a lock, and whether the file system tells names apart by case: where the caller says, no probe file is written (a store that must not write where it is opened, such as one at the root of a computer's file system, says); where it does not, a probe file is made and removed. The locks of writers are kept in lockDir, an absolute folder, where it is given, and in a folder of the store's own where it is not: a store at the root of a file system names a folder of the account's own, since the root is not the account's to write.
localStorefunctionfunction localStore(root: string, options?: LocalOptions): Promise<Result<LocalStore, string>>A store in a folder, or why there is none. The folder must be an absolute path.