IF Commons GitHub

physical/local/mod

Written to: 2 requirements: 2 proved, 0 partly, 0 failing, 0 with no test recorded. 0005-anyfs-conformance FR-004, 0005-anyfs-conformance FR-005

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"

Source: commons/anyfs/src/physical/local/mod.ts

2 of 4 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

LOCAL_CAPABILITIESconst
const LOCAL_CAPABILITIES: readonly ["read", "write", "list", "stat", "delete", "cas", "rename"]

The capabilities of the store in a folder.

Imported by 9 tests of the run (9 passed, 0 failed): the library's results

LocalStoretypeno test imports it
type LocalStore = Store<(typeof LOCAL_CAPABILITIES)[number]>;

The type of the store in a folder.

LocalOptionstypeno test imports it
type 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.

localStorefunction
function 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.

Imported by 20 tests of the run (20 passed, 0 failed): the library's results

Titles, headings, exports, tables, columns and requirements. Esc closes.