@fnndsc/fond 0.6.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -3
- package/dist/errorStack.d.ts +10 -6
- package/dist/errorStack.js +12 -9
- package/dist/errorStack.js.map +1 -1
- package/dist/heldWriter.d.ts +130 -0
- package/dist/heldWriter.js +539 -0
- package/dist/heldWriter.js.map +1 -0
- package/dist/homePath.d.ts +60 -0
- package/dist/homePath.js +117 -0
- package/dist/homePath.js.map +1 -0
- package/dist/hostPlace.d.ts +275 -0
- package/dist/hostPlace.js +777 -0
- package/dist/hostPlace.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/placedPath.d.ts +250 -0
- package/dist/placedPath.js +757 -0
- package/dist/placedPath.js.map +1 -0
- package/dist/publication.d.ts +43 -0
- package/dist/publication.js +55 -0
- package/dist/publication.js.map +1 -0
- package/dist/recordFile.d.ts +61 -0
- package/dist/recordFile.js +258 -0
- package/dist/recordFile.js.map +1 -0
- package/dist/vfs/contract.js +19 -5
- package/dist/vfs/contract.js.map +1 -1
- package/dist/vfs/dispatcher.d.ts +222 -13
- package/dist/vfs/dispatcher.js +483 -73
- package/dist/vfs/dispatcher.js.map +1 -1
- package/dist/vfs/memory.d.ts +107 -3
- package/dist/vfs/memory.js +198 -24
- package/dist/vfs/memory.js.map +1 -1
- package/dist/vfs/naming.d.ts +97 -0
- package/dist/vfs/naming.js +122 -0
- package/dist/vfs/naming.js.map +1 -0
- package/dist/vfs/outcome.d.ts +72 -2
- package/dist/vfs/outcome.js +84 -3
- package/dist/vfs/outcome.js.map +1 -1
- package/dist/vfs/provider.d.ts +191 -6
- package/dist/vfs/render.d.ts +7 -0
- package/dist/vfs/render.js +16 -13
- package/dist/vfs/render.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Where a copy puts what it names, and what a copy that fell short says.
|
|
3
|
+
*
|
|
4
|
+
* A copy into a folder takes a name there, and that name may come from a
|
|
5
|
+
* caller the mount does not trust: it must be one component (not empty, no
|
|
6
|
+
* `/`, no NUL, not `.` or `..`), and the path it makes must sit directly
|
|
7
|
+
* inside the folder chosen. A copy of a folder writes many entries, and a
|
|
8
|
+
* refusal of some of them says which came first, why, and how many.
|
|
9
|
+
*
|
|
10
|
+
* Key components:
|
|
11
|
+
* - entryName_check: one untrusted name, as one component, or `EINVAL`.
|
|
12
|
+
* - childPath_join: a folder and a name, as the one path directly inside it.
|
|
13
|
+
* - CopyRefusal, CopyShortfall, copyShortfall_say: a copy's tally of what it did not write, in words.
|
|
14
|
+
*
|
|
15
|
+
* Typical usage:
|
|
16
|
+
* ```ts
|
|
17
|
+
* const final: VfsOutcome<string> = childPath_join('/home/ada/backup', 'docs');
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* Dependencies: the outcome of `./outcome.js`.
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
import { type VfsOutcome } from './outcome.js';
|
|
25
|
+
/**
|
|
26
|
+
* Checks that a name a copy will take is one component.
|
|
27
|
+
*
|
|
28
|
+
* @param name - The name, as a caller gave it.
|
|
29
|
+
* @returns The name, or `EINVAL` saying why it is not one component.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* entryName_check('..'); // { ok: false, errno: 'EINVAL', reason: ... }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function entryName_check(name: string): VfsOutcome<string>;
|
|
37
|
+
/**
|
|
38
|
+
* The path a name takes directly inside a folder.
|
|
39
|
+
*
|
|
40
|
+
* @param folder - The folder's absolute path.
|
|
41
|
+
* @param name - The name, checked as one component ({@link entryName_check}).
|
|
42
|
+
* @returns The path, or `EINVAL` when the name is not one component or the
|
|
43
|
+
* path would not sit directly inside the folder.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* childPath_join('/home/ada/backup', 'docs'); // { ok: true, value: '/home/ada/backup/docs' }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function childPath_join(folder: string, name: string): VfsOutcome<string>;
|
|
51
|
+
/**
|
|
52
|
+
* The first entry a copy did not write: its name below the source, and why.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const first: CopyRefusal = { relative: 'sub', cause: 'already held' };
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export interface CopyRefusal {
|
|
60
|
+
/** Its name below the source: plain parts joined by `/`. */
|
|
61
|
+
readonly relative: string;
|
|
62
|
+
/** Why it was not written, in words. */
|
|
63
|
+
readonly cause: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* What a copy of a folder did not write: how many entries the source held,
|
|
67
|
+
* how many were refused or failed, how many below a refused folder were
|
|
68
|
+
* never tried, and the first refused, with why.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* const tally: CopyShortfall = { total: 3, failed: 1, untried: 1, first: { relative: 'sub', cause: 'already held' } };
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export interface CopyShortfall {
|
|
76
|
+
/** Entries the source held. */
|
|
77
|
+
readonly total: number;
|
|
78
|
+
/** Entries refused or failed. */
|
|
79
|
+
readonly failed: number;
|
|
80
|
+
/** Entries below a refused folder, never tried. */
|
|
81
|
+
readonly untried: number;
|
|
82
|
+
/** The first entry refused, by its name below the source, and why. */
|
|
83
|
+
readonly first: CopyRefusal | null;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A copy's shortfall, in the words its refusal carries.
|
|
87
|
+
*
|
|
88
|
+
* @param dest - The folder the copy became.
|
|
89
|
+
* @param tally - What it did not write.
|
|
90
|
+
* @returns The sentence.
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```ts
|
|
94
|
+
* copyShortfall_say('/home/ada/backup', tally); // 'copy to /home/ada/backup: 1 of 3 entries not copied, the first sub (already held); ...'
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
export declare function copyShortfall_say(dest: string, tally: CopyShortfall): string;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Where a copy puts what it names, and what a copy that fell short says.
|
|
4
|
+
*
|
|
5
|
+
* A copy into a folder takes a name there, and that name may come from a
|
|
6
|
+
* caller the mount does not trust: it must be one component (not empty, no
|
|
7
|
+
* `/`, no NUL, not `.` or `..`), and the path it makes must sit directly
|
|
8
|
+
* inside the folder chosen. A copy of a folder writes many entries, and a
|
|
9
|
+
* refusal of some of them says which came first, why, and how many.
|
|
10
|
+
*
|
|
11
|
+
* Key components:
|
|
12
|
+
* - entryName_check: one untrusted name, as one component, or `EINVAL`.
|
|
13
|
+
* - childPath_join: a folder and a name, as the one path directly inside it.
|
|
14
|
+
* - CopyRefusal, CopyShortfall, copyShortfall_say: a copy's tally of what it did not write, in words.
|
|
15
|
+
*
|
|
16
|
+
* Typical usage:
|
|
17
|
+
* ```ts
|
|
18
|
+
* const final: VfsOutcome<string> = childPath_join('/home/ada/backup', 'docs');
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Dependencies: the outcome of `./outcome.js`.
|
|
22
|
+
*
|
|
23
|
+
* @module
|
|
24
|
+
*/
|
|
25
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
28
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
29
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(o, k2, desc);
|
|
32
|
+
}) : (function(o, m, k, k2) {
|
|
33
|
+
if (k2 === undefined) k2 = k;
|
|
34
|
+
o[k2] = m[k];
|
|
35
|
+
}));
|
|
36
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
37
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
38
|
+
}) : function(o, v) {
|
|
39
|
+
o["default"] = v;
|
|
40
|
+
});
|
|
41
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
42
|
+
var ownKeys = function(o) {
|
|
43
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
44
|
+
var ar = [];
|
|
45
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
46
|
+
return ar;
|
|
47
|
+
};
|
|
48
|
+
return ownKeys(o);
|
|
49
|
+
};
|
|
50
|
+
return function (mod) {
|
|
51
|
+
if (mod && mod.__esModule) return mod;
|
|
52
|
+
var result = {};
|
|
53
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
54
|
+
__setModuleDefault(result, mod);
|
|
55
|
+
return result;
|
|
56
|
+
};
|
|
57
|
+
})();
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.entryName_check = entryName_check;
|
|
60
|
+
exports.childPath_join = childPath_join;
|
|
61
|
+
exports.copyShortfall_say = copyShortfall_say;
|
|
62
|
+
const path = __importStar(require("path"));
|
|
63
|
+
const outcome_js_1 = require("./outcome.js");
|
|
64
|
+
/**
|
|
65
|
+
* Checks that a name a copy will take is one component.
|
|
66
|
+
*
|
|
67
|
+
* @param name - The name, as a caller gave it.
|
|
68
|
+
* @returns The name, or `EINVAL` saying why it is not one component.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```ts
|
|
72
|
+
* entryName_check('..'); // { ok: false, errno: 'EINVAL', reason: ... }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
function entryName_check(name) {
|
|
76
|
+
const why = name === '' ? 'is empty'
|
|
77
|
+
: name === '.' || name === '..' ? `is ${name}`
|
|
78
|
+
: name.includes('/') ? 'holds a slash'
|
|
79
|
+
: name.includes('\0') ? 'holds a NUL' : null;
|
|
80
|
+
return why === null ? (0, outcome_js_1.vfs_ok)(name) : (0, outcome_js_1.vfs_fail)('EINVAL', `the name ${JSON.stringify(name)} ${why}, and is not one name: nothing was copied`);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The path a name takes directly inside a folder.
|
|
84
|
+
*
|
|
85
|
+
* @param folder - The folder's absolute path.
|
|
86
|
+
* @param name - The name, checked as one component ({@link entryName_check}).
|
|
87
|
+
* @returns The path, or `EINVAL` when the name is not one component or the
|
|
88
|
+
* path would not sit directly inside the folder.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```ts
|
|
92
|
+
* childPath_join('/home/ada/backup', 'docs'); // { ok: true, value: '/home/ada/backup/docs' }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
function childPath_join(folder, name) {
|
|
96
|
+
const named = entryName_check(name);
|
|
97
|
+
if (!named.ok)
|
|
98
|
+
return named;
|
|
99
|
+
const joined = path.posix.join(folder, name);
|
|
100
|
+
if (path.posix.dirname(joined) !== path.posix.resolve('/', folder) || path.posix.basename(joined) !== name) {
|
|
101
|
+
return (0, outcome_js_1.vfs_fail)('EINVAL', `${JSON.stringify(name)} would not land directly inside ${folder}: nothing was copied`);
|
|
102
|
+
}
|
|
103
|
+
return (0, outcome_js_1.vfs_ok)(joined);
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* A copy's shortfall, in the words its refusal carries.
|
|
107
|
+
*
|
|
108
|
+
* @param dest - The folder the copy became.
|
|
109
|
+
* @param tally - What it did not write.
|
|
110
|
+
* @returns The sentence.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* copyShortfall_say('/home/ada/backup', tally); // 'copy to /home/ada/backup: 1 of 3 entries not copied, the first sub (already held); ...'
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
function copyShortfall_say(dest, tally) {
|
|
118
|
+
const first = tally.first === null ? '' : `, the first ${tally.first.relative} (${tally.first.cause})`;
|
|
119
|
+
const untried = tally.untried === 0 ? '' : `; ${String(tally.untried)} ${tally.untried === 1 ? 'entry' : 'entries'} below a refused folder not tried`;
|
|
120
|
+
return `copy to ${dest}: ${String(tally.failed)} of ${String(tally.total)} entries not copied${first}${untried}; nothing was written over`;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=naming.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"naming.js","sourceRoot":"","sources":["../../src/vfs/naming.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBH,0CAMC;AAeD,wCAQC;AAkDD,8CAIC;AAlGD,2CAA6B;AAE7B,6CAAiE;AAEjE;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAAC,IAAY;IAC1C,MAAM,GAAG,GAAkB,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,UAAU;QACjD,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE;YAC5C,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe;gBACpC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC;IACnD,OAAO,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAA,mBAAM,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAA,qBAAQ,EAA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AAC,CAAC,CAAC,SAAS,mCAAmC,CAAC;IAC9J,OAAO,WAAW,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,sBAAsB,KAAK,GAAG,OAAO,4BAA4B,CAAC;AAC7I,CAAC"}
|
package/dist/vfs/outcome.d.ts
CHANGED
|
@@ -10,16 +10,32 @@
|
|
|
10
10
|
* @module
|
|
11
11
|
*/
|
|
12
12
|
import { Result } from '../result.js';
|
|
13
|
+
import type { HolderProof } from './provider.js';
|
|
13
14
|
/** Why a filesystem operation failed. */
|
|
14
|
-
export type VfsErrno = 'ENOENT' | 'EEXIST' | 'EISDIR' | 'ENOTDIR' | 'ENOTEMPTY' | 'EROFS' | 'EXDEV' | 'EACCES' | 'EPERM' | 'EIO';
|
|
15
|
-
/**
|
|
15
|
+
export type VfsErrno = 'ENOENT' | 'EEXIST' | 'EISDIR' | 'ENOTDIR' | 'ENOTEMPTY' | 'EROFS' | 'EXDEV' | 'EACCES' | 'EPERM' | 'EINVAL' | 'EINPROGRESS' | 'EIO';
|
|
16
|
+
/**
|
|
17
|
+
* An operation's answer: its value, or why it failed and, perhaps, the
|
|
18
|
+
* mount's own reason. An `EEXIST` may say what the mount proved holds the
|
|
19
|
+
* path (`held`): a proof, or null when something is there that the mount
|
|
20
|
+
* could not name; absent when the mount does not say. A success may say
|
|
21
|
+
* that what it was to make is there with its maker not known (`present`).
|
|
22
|
+
*/
|
|
16
23
|
export type VfsOutcome<T = true> = {
|
|
24
|
+
/** Done. */
|
|
17
25
|
ok: true;
|
|
26
|
+
/** What the operation gives back. */
|
|
18
27
|
value: T;
|
|
28
|
+
/** What was to be made is there, but the store did not answer the request to make it: whether this made it or found it is not known. */
|
|
29
|
+
present?: true;
|
|
19
30
|
} | {
|
|
31
|
+
/** Not done. */
|
|
20
32
|
ok: false;
|
|
33
|
+
/** Why, as a kernel says it. */
|
|
21
34
|
errno: VfsErrno;
|
|
35
|
+
/** The mount's own words, when it knows more than the errno says. */
|
|
22
36
|
reason?: string;
|
|
37
|
+
/** For an `EEXIST`, what the mount proved holds the path; null when it could not name it; absent when it does not say. */
|
|
38
|
+
held?: HolderProof | null;
|
|
23
39
|
};
|
|
24
40
|
/**
|
|
25
41
|
* A success.
|
|
@@ -28,6 +44,20 @@ export type VfsOutcome<T = true> = {
|
|
|
28
44
|
* @returns The outcome.
|
|
29
45
|
*/
|
|
30
46
|
export declare function vfs_ok<T>(value: T): VfsOutcome<T>;
|
|
47
|
+
/**
|
|
48
|
+
* A success whose maker is not known: what was to be made is there, but the
|
|
49
|
+
* store did not answer the request to make it, so it may have been made by
|
|
50
|
+
* this request or found there. Never reported as made.
|
|
51
|
+
*
|
|
52
|
+
* @param value - What the operation gives back.
|
|
53
|
+
* @returns The outcome, `present` set.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* return vfs_okPresent(true);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function vfs_okPresent<T>(value: T): VfsOutcome<T>;
|
|
31
61
|
/**
|
|
32
62
|
* A failure.
|
|
33
63
|
*
|
|
@@ -36,6 +66,46 @@ export declare function vfs_ok<T>(value: T): VfsOutcome<T>;
|
|
|
36
66
|
* @returns The outcome.
|
|
37
67
|
*/
|
|
38
68
|
export declare function vfs_fail<T = never>(errno: VfsErrno, reason?: string): VfsOutcome<T>;
|
|
69
|
+
/**
|
|
70
|
+
* An `EEXIST`, carrying what the mount proved holds the path.
|
|
71
|
+
*
|
|
72
|
+
* @param held - The proof; null when something is there that the mount could not name.
|
|
73
|
+
* @returns The outcome.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const twins: VfsOutcome = vfs_failHeld({ kind: 'ambiguous', holders: ['dir', 'file'] });
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export declare function vfs_failHeld<T = never>(held: HolderProof | null): VfsOutcome<T>;
|
|
81
|
+
/**
|
|
82
|
+
* An operation the store accepted and was not seen to finish: a removal CUBE
|
|
83
|
+
* queued, whose thing still answered (or no answer came) by the deadline.
|
|
84
|
+
* It is a failure to every caller that counts what was done, since it was
|
|
85
|
+
* not seen done, and it is not "nothing happened" either: what a cache holds
|
|
86
|
+
* of the place is stale all the same.
|
|
87
|
+
*
|
|
88
|
+
* @param reason - What was accepted, and what was not seen.
|
|
89
|
+
* @returns The outcome, errno `EINPROGRESS`.
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```ts
|
|
93
|
+
* return vfs_unconfirmed('CUBE accepted the removal of /home/ada/x and did not confirm it within 15s');
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
export declare function vfs_unconfirmed<T = never>(reason: string): VfsOutcome<T>;
|
|
97
|
+
/**
|
|
98
|
+
* Whether an outcome is an accepted operation not seen to finish ({@link vfs_unconfirmed}).
|
|
99
|
+
*
|
|
100
|
+
* @param outcome - The outcome.
|
|
101
|
+
* @returns True for `EINPROGRESS`.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* if (vfsOutcome_isUnconfirmed(removed)) listings_forget(target);
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function vfsOutcome_isUnconfirmed<T>(outcome: VfsOutcome<T>): boolean;
|
|
39
109
|
/** The operations whose refusals are worded here. */
|
|
40
110
|
export type VfsOperation = 'read' | 'readBinary' | 'write' | 'mkdir' | 'rmdir' | 'rename' | 'rm' | 'cp';
|
|
41
111
|
/**
|
package/dist/vfs/outcome.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vfs_ok = vfs_ok;
|
|
4
|
+
exports.vfs_okPresent = vfs_okPresent;
|
|
4
5
|
exports.vfs_fail = vfs_fail;
|
|
6
|
+
exports.vfs_failHeld = vfs_failHeld;
|
|
7
|
+
exports.vfs_unconfirmed = vfs_unconfirmed;
|
|
8
|
+
exports.vfsOutcome_isUnconfirmed = vfsOutcome_isUnconfirmed;
|
|
5
9
|
exports.errno_words = errno_words;
|
|
6
10
|
exports.vfsRefusal_text = vfsRefusal_text;
|
|
7
11
|
exports.vfs_failFromStack = vfs_failFromStack;
|
|
@@ -30,6 +34,22 @@ const errorStack_js_1 = require("../errorStack.js");
|
|
|
30
34
|
function vfs_ok(value) {
|
|
31
35
|
return { ok: true, value };
|
|
32
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* A success whose maker is not known: what was to be made is there, but the
|
|
39
|
+
* store did not answer the request to make it, so it may have been made by
|
|
40
|
+
* this request or found there. Never reported as made.
|
|
41
|
+
*
|
|
42
|
+
* @param value - What the operation gives back.
|
|
43
|
+
* @returns The outcome, `present` set.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* return vfs_okPresent(true);
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
function vfs_okPresent(value) {
|
|
51
|
+
return { ok: true, value, present: true };
|
|
52
|
+
}
|
|
33
53
|
/**
|
|
34
54
|
* A failure.
|
|
35
55
|
*
|
|
@@ -40,6 +60,52 @@ function vfs_ok(value) {
|
|
|
40
60
|
function vfs_fail(errno, reason) {
|
|
41
61
|
return reason === undefined ? { ok: false, errno } : { ok: false, errno, reason };
|
|
42
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* An `EEXIST`, carrying what the mount proved holds the path.
|
|
65
|
+
*
|
|
66
|
+
* @param held - The proof; null when something is there that the mount could not name.
|
|
67
|
+
* @returns The outcome.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* const twins: VfsOutcome = vfs_failHeld({ kind: 'ambiguous', holders: ['dir', 'file'] });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
function vfs_failHeld(held) {
|
|
75
|
+
return { ok: false, errno: 'EEXIST', held };
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* An operation the store accepted and was not seen to finish: a removal CUBE
|
|
79
|
+
* queued, whose thing still answered (or no answer came) by the deadline.
|
|
80
|
+
* It is a failure to every caller that counts what was done, since it was
|
|
81
|
+
* not seen done, and it is not "nothing happened" either: what a cache holds
|
|
82
|
+
* of the place is stale all the same.
|
|
83
|
+
*
|
|
84
|
+
* @param reason - What was accepted, and what was not seen.
|
|
85
|
+
* @returns The outcome, errno `EINPROGRESS`.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```ts
|
|
89
|
+
* return vfs_unconfirmed('CUBE accepted the removal of /home/ada/x and did not confirm it within 15s');
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
function vfs_unconfirmed(reason) {
|
|
93
|
+
return vfs_fail('EINPROGRESS', reason);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether an outcome is an accepted operation not seen to finish ({@link vfs_unconfirmed}).
|
|
97
|
+
*
|
|
98
|
+
* @param outcome - The outcome.
|
|
99
|
+
* @returns True for `EINPROGRESS`.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```ts
|
|
103
|
+
* if (vfsOutcome_isUnconfirmed(removed)) listings_forget(target);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
function vfsOutcome_isUnconfirmed(outcome) {
|
|
107
|
+
return !outcome.ok && outcome.errno === 'EINPROGRESS';
|
|
108
|
+
}
|
|
43
109
|
/** The errno's own words, as `strerror` gives them. */
|
|
44
110
|
const ERRNO_WORDS = {
|
|
45
111
|
ENOENT: 'No such file or directory',
|
|
@@ -51,6 +117,8 @@ const ERRNO_WORDS = {
|
|
|
51
117
|
EXDEV: 'Invalid cross-device link',
|
|
52
118
|
EACCES: 'Permission denied',
|
|
53
119
|
EPERM: 'Operation not permitted',
|
|
120
|
+
EINVAL: 'Invalid argument',
|
|
121
|
+
EINPROGRESS: 'Operation now in progress',
|
|
54
122
|
EIO: 'Input/output error',
|
|
55
123
|
};
|
|
56
124
|
/**
|
|
@@ -62,6 +130,19 @@ const ERRNO_WORDS = {
|
|
|
62
130
|
function errno_words(errno) {
|
|
63
131
|
return ERRNO_WORDS[errno];
|
|
64
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* What an operator reads when a read or write of a file failed: that the
|
|
135
|
+
* mount offers no such access (EROFS), else the path and the errno's words.
|
|
136
|
+
*
|
|
137
|
+
* @param access - The access as a sentence starts it (`File read`).
|
|
138
|
+
* @param errno - Why it failed.
|
|
139
|
+
* @param path - The path it was asked of.
|
|
140
|
+
* @param words - The errno in words.
|
|
141
|
+
* @returns The sentence.
|
|
142
|
+
*/
|
|
143
|
+
function fileAccessRefusal_text(access, errno, path, words) {
|
|
144
|
+
return errno === 'EROFS' ? `${access} not supported for path: ${path}` : `${path}: ${words}`;
|
|
145
|
+
}
|
|
65
146
|
/**
|
|
66
147
|
* What an operator reads when an operation failed: the mount's own reason
|
|
67
148
|
* when it gave one, else the operation's sentence for the errno.
|
|
@@ -78,11 +159,11 @@ function vfsRefusal_text(operation, outcome, path, dest) {
|
|
|
78
159
|
const words = errno_words(outcome.errno);
|
|
79
160
|
switch (operation) {
|
|
80
161
|
case 'read':
|
|
81
|
-
return
|
|
162
|
+
return fileAccessRefusal_text('File read', outcome.errno, path, words);
|
|
82
163
|
case 'readBinary':
|
|
83
|
-
return
|
|
164
|
+
return fileAccessRefusal_text('Binary file read', outcome.errno, path, words);
|
|
84
165
|
case 'write':
|
|
85
|
-
return
|
|
166
|
+
return fileAccessRefusal_text('File write', outcome.errno, path, words);
|
|
86
167
|
case 'mkdir':
|
|
87
168
|
return `mkdir: cannot create directory '${path}': ${words}`;
|
|
88
169
|
case 'rmdir':
|
package/dist/vfs/outcome.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.js","sourceRoot":"","sources":["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