@fnndsc/salsa 4.5.6 → 4.6.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 +0 -2
- package/dist/compute/index.d.ts +0 -9
- package/dist/compute/index.js +0 -16
- package/dist/compute/index.js.map +1 -1
- package/dist/dag/feedData.js +166 -73
- package/dist/dag/feedData.js.map +1 -1
- package/dist/dag/feedLoad.d.ts +1 -1
- package/dist/dag/feedLoad.js +6 -4
- package/dist/dag/feedLoad.js.map +1 -1
- package/dist/dicom/pixels.js +95 -36
- package/dist/dicom/pixels.js.map +1 -1
- package/dist/dicom/series.d.ts +4 -1
- package/dist/dicom/series.js +80 -31
- package/dist/dicom/series.js.map +1 -1
- package/dist/dicom/tags.d.ts +28 -0
- package/dist/dicom/tags.js +30 -0
- package/dist/dicom/tags.js.map +1 -1
- package/dist/files/copy.d.ts +197 -0
- package/dist/files/copy.js +636 -0
- package/dist/files/copy.js.map +1 -0
- package/dist/files/copyFolder.d.ts +103 -0
- package/dist/files/copyFolder.js +199 -0
- package/dist/files/copyFolder.js.map +1 -0
- package/dist/files/create.d.ts +178 -0
- package/dist/files/create.js +444 -0
- package/dist/files/create.js.map +1 -0
- package/dist/files/download.d.ts +188 -0
- package/dist/files/download.js +541 -0
- package/dist/files/download.js.map +1 -0
- package/dist/files/index.d.ts +69 -141
- package/dist/files/index.js +184 -535
- package/dist/files/index.js.map +1 -1
- package/dist/files/listing.d.ts +132 -0
- package/dist/files/listing.js +179 -0
- package/dist/files/listing.js.map +1 -0
- package/dist/files/move.d.ts +125 -0
- package/dist/files/move.js +334 -0
- package/dist/files/move.js.map +1 -0
- package/dist/files/pathMapper.d.ts +24 -1
- package/dist/files/pathMapper.js +108 -47
- package/dist/files/pathMapper.js.map +1 -1
- package/dist/files/proof.d.ts +315 -0
- package/dist/files/proof.js +574 -0
- package/dist/files/proof.js.map +1 -0
- package/dist/files/removal.d.ts +223 -0
- package/dist/files/removal.js +318 -0
- package/dist/files/removal.js.map +1 -0
- package/dist/files/replace.d.ts +175 -0
- package/dist/files/replace.js +582 -0
- package/dist/files/replace.js.map +1 -0
- package/dist/files/upload.d.ts +205 -0
- package/dist/files/upload.js +478 -0
- package/dist/files/upload.js.map +1 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.js +45 -32
- package/dist/index.js.map +1 -1
- package/dist/jobs/index.d.ts +1 -1
- package/dist/jobs/index.js +2 -2
- package/dist/jobs/index.js.map +1 -1
- package/dist/jobs/jobOps.d.ts +20 -13
- package/dist/jobs/jobOps.js +41 -37
- package/dist/jobs/jobOps.js.map +1 -1
- package/dist/pacs/anonymise.d.ts +17 -36
- package/dist/pacs/anonymise.js +29 -67
- package/dist/pacs/anonymise.js.map +1 -1
- package/dist/pipelines/index.d.ts +1 -13
- package/dist/pipelines/index.js +0 -38
- package/dist/pipelines/index.js.map +1 -1
- package/dist/pipelines/invocation.js +321 -167
- package/dist/pipelines/invocation.js.map +1 -1
- package/dist/pipelines/manifest.js.map +1 -1
- package/dist/pipelines/packages.d.ts +11 -8
- package/dist/pipelines/packages.js +253 -77
- package/dist/pipelines/packages.js.map +1 -1
- package/dist/plugins/adminToken.d.ts +67 -0
- package/dist/plugins/adminToken.js +77 -0
- package/dist/plugins/adminToken.js.map +1 -0
- package/dist/plugins/index.d.ts +0 -7
- package/dist/plugins/index.js +0 -16
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/peer_search.d.ts +0 -15
- package/dist/plugins/peer_search.js +0 -25
- package/dist/plugins/peer_search.js.map +1 -1
- package/dist/plugins/plugin_add.d.ts +14 -2
- package/dist/plugins/plugin_add.js +42 -13
- package/dist/plugins/plugin_add.js.map +1 -1
- package/dist/plugins/plugin_docker.d.ts +25 -0
- package/dist/plugins/plugin_docker.js +33 -0
- package/dist/plugins/plugin_docker.js.map +1 -1
- package/dist/plugins/plugin_register.d.ts +0 -10
- package/dist/plugins/plugin_register.js +3 -54
- package/dist/plugins/plugin_register.js.map +1 -1
- package/dist/plugins/plugin_sync.js +45 -22
- package/dist/plugins/plugin_sync.js.map +1 -1
- package/dist/plugins/plugin_validate.js +47 -13
- package/dist/plugins/plugin_validate.js.map +1 -1
- package/dist/plugins/store_import.d.ts +0 -9
- package/dist/plugins/store_import.js +3 -29
- package/dist/plugins/store_import.js.map +1 -1
- package/dist/retrieve/task.d.ts +137 -0
- package/dist/retrieve/task.js +41 -0
- package/dist/retrieve/task.js.map +1 -0
- package/dist/retrieve/watch.d.ts +2 -118
- package/dist/retrieve/watch.js +452 -321
- package/dist/retrieve/watch.js.map +1 -1
- package/dist/vfs/providers/etc.d.ts +6 -4
- package/dist/vfs/providers/etc.js +12 -4
- package/dist/vfs/providers/etc.js.map +1 -1
- package/dist/vfs/providers/native.d.ts +116 -39
- package/dist/vfs/providers/native.js +291 -347
- package/dist/vfs/providers/native.js.map +1 -1
- package/dist/vfs/providers/pacs.d.ts +29 -3
- package/dist/vfs/providers/pacs.js +303 -73
- package/dist/vfs/providers/pacs.js.map +1 -1
- package/dist/vfs/providers/pacs_content.js +22 -6
- package/dist/vfs/providers/pacs_content.js.map +1 -1
- package/dist/vfs/providers/proc/backfill.d.ts +46 -0
- package/dist/vfs/providers/proc/backfill.js +147 -0
- package/dist/vfs/providers/proc/backfill.js.map +1 -0
- package/dist/vfs/providers/proc/book.d.ts +176 -0
- package/dist/vfs/providers/proc/book.js +73 -0
- package/dist/vfs/providers/proc/book.js.map +1 -0
- package/dist/vfs/providers/proc/catchup.d.ts +69 -0
- package/dist/vfs/providers/proc/catchup.js +125 -0
- package/dist/vfs/providers/proc/catchup.js.map +1 -0
- package/dist/vfs/providers/proc/feedIndex.d.ts +146 -0
- package/dist/vfs/providers/proc/feedIndex.js +354 -0
- package/dist/vfs/providers/proc/feedIndex.js.map +1 -0
- package/dist/vfs/providers/proc/feedTopology.d.ts +85 -0
- package/dist/vfs/providers/proc/feedTopology.js +192 -0
- package/dist/vfs/providers/proc/feedTopology.js.map +1 -0
- package/dist/vfs/providers/proc/locate.d.ts +60 -0
- package/dist/vfs/providers/proc/locate.js +103 -0
- package/dist/vfs/providers/proc/locate.js.map +1 -0
- package/dist/vfs/providers/proc/path.d.ts +50 -0
- package/dist/vfs/providers/proc/path.js +106 -0
- package/dist/vfs/providers/proc/path.js.map +1 -0
- package/dist/vfs/providers/proc/roster.d.ts +95 -0
- package/dist/vfs/providers/proc/roster.js +425 -0
- package/dist/vfs/providers/proc/roster.js.map +1 -0
- package/dist/vfs/providers/proc/rows.d.ts +120 -0
- package/dist/vfs/providers/proc/rows.js +181 -0
- package/dist/vfs/providers/proc/rows.js.map +1 -0
- package/dist/vfs/providers/proc/subtree.d.ts +73 -0
- package/dist/vfs/providers/proc/subtree.js +125 -0
- package/dist/vfs/providers/proc/subtree.js.map +1 -0
- package/dist/vfs/providers/proc/sweep.d.ts +89 -0
- package/dist/vfs/providers/proc/sweep.js +297 -0
- package/dist/vfs/providers/proc/sweep.js.map +1 -0
- package/dist/vfs/providers/proc.d.ts +47 -346
- package/dist/vfs/providers/proc.js +349 -1806
- package/dist/vfs/providers/proc.js.map +1 -1
- package/dist/vfs/providers/share.js +4 -1
- package/dist/vfs/providers/share.js.map +1 -1
- package/package.json +3 -3
- package/dist/pacs/resultDecode.d.ts +0 -13
- package/dist/pacs/resultDecode.js +0 -19
- package/dist/pacs/resultDecode.js.map +0 -1
|
@@ -12,15 +12,32 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
exports.NativeVfsProvider = void 0;
|
|
14
14
|
exports.chrisRow_convertToItem = chrisRow_convertToItem;
|
|
15
|
-
const
|
|
15
|
+
const path_1 = __importDefault(require("path"));
|
|
16
16
|
const cumin_1 = require("@fnndsc/cumin");
|
|
17
|
-
const
|
|
17
|
+
const fond_1 = require("@fnndsc/fond");
|
|
18
|
+
const copy_js_1 = require("../../files/copy.js");
|
|
19
|
+
const create_js_1 = require("../../files/create.js");
|
|
18
20
|
const index_js_1 = require("../../files/index.js");
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
const move_js_1 = require("../../files/move.js");
|
|
22
|
+
const proof_js_1 = require("../../files/proof.js");
|
|
23
|
+
const removal_js_1 = require("../../files/removal.js");
|
|
24
|
+
const sort_js_1 = require("../sort.js");
|
|
25
|
+
/**
|
|
26
|
+
* A removal's outcome as the filesystem says it: an accepted removal not
|
|
27
|
+
* seen done is `EINPROGRESS`, never success.
|
|
28
|
+
*
|
|
29
|
+
* @param removed - What the removal came to.
|
|
30
|
+
* @returns The outcome.
|
|
31
|
+
*/
|
|
32
|
+
function removal_convertToOutcome(removed) {
|
|
33
|
+
if (removed.kind === 'removed')
|
|
34
|
+
return (0, fond_1.vfs_ok)(true);
|
|
35
|
+
if (removed.kind === 'absent')
|
|
36
|
+
return (0, fond_1.vfs_fail)('ENOENT');
|
|
37
|
+
if (removed.kind === 'unconfirmed')
|
|
38
|
+
return (0, fond_1.vfs_unconfirmed)(removed.reason);
|
|
39
|
+
return removed.reason === undefined ? (0, fond_1.vfs_fail)(removed.errno) : (0, fond_1.vfs_fail)(removed.errno, removed.reason);
|
|
40
|
+
}
|
|
24
41
|
/**
|
|
25
42
|
* One CUBE files/dirs/links row as a listing item: its name (the last path
|
|
26
43
|
* segment, a link's `.chrislink` dropped) and, for a link, where it points.
|
|
@@ -57,94 +74,41 @@ function chrisRow_convertToItem(raw, type) {
|
|
|
57
74
|
class NativeVfsProvider {
|
|
58
75
|
/** Prefix matches everything. */
|
|
59
76
|
prefix = "";
|
|
77
|
+
/** A copy or a move into a folder proves it one folder and refuses anything else (`path_copy`, `path_move`). */
|
|
78
|
+
intoFolderOffered = true;
|
|
79
|
+
/** How long a removal waits to see what it removed gone, and how often it asks. */
|
|
80
|
+
removalWait;
|
|
81
|
+
/**
|
|
82
|
+
* @param removalWait - The wait a removal makes for CUBE to finish what it accepted.
|
|
83
|
+
*/
|
|
84
|
+
constructor(removalWait = removal_js_1.REMOVAL_WAIT) {
|
|
85
|
+
this.removalWait = removalWait;
|
|
86
|
+
}
|
|
60
87
|
/**
|
|
61
88
|
* Lists native ChRIS folder contents (dirs, files, links).
|
|
62
89
|
*
|
|
90
|
+
* A sub-listing that could not be read is never an empty one: beside
|
|
91
|
+
* rows that were read it is named on the error stack, and with no rows
|
|
92
|
+
* the listing fails with it. An empty folder is one whose three listings
|
|
93
|
+
* were each read, whole first pages with nothing in them. When no
|
|
94
|
+
* listing could be made at all, the path is settled fresh
|
|
95
|
+
* ({@link folderUnlisted_settle}): a folder found there is listed by its
|
|
96
|
+
* id, one not read whole or any proof that failed is an error, and "No such file or directory"
|
|
97
|
+
* only when its parent proves nothing there. A folder of mounts has no
|
|
98
|
+
* folder of CUBE's behind it: the store holds nothing there.
|
|
99
|
+
*
|
|
63
100
|
* @param pathStr - Absolute directory path.
|
|
64
101
|
* @param options - Sorting parameters.
|
|
102
|
+
* @returns The rows, or Err with the reason stacked.
|
|
65
103
|
*/
|
|
66
104
|
async list(pathStr, options) {
|
|
105
|
+
const resolvedPath = pathStr || "/";
|
|
106
|
+
if ((0, index_js_1.path_isProjection)(resolvedPath))
|
|
107
|
+
return (0, cumin_1.Ok)([]);
|
|
67
108
|
try {
|
|
68
109
|
const fetchOpts = { limit: 1000, offset: 0 };
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
// refusal from an empty folder, which is the whole point: they read
|
|
72
|
-
// the same on screen and only one of them is true (#462).
|
|
73
|
-
const outcomes = await Promise.all([
|
|
74
|
-
(0, index_js_1.files_listOutcome)(fetchOpts, "dirs", resolvedPath),
|
|
75
|
-
(0, index_js_1.files_listOutcome)(fetchOpts, "files", resolvedPath),
|
|
76
|
-
(0, index_js_1.files_listOutcome)(fetchOpts, "links", resolvedPath),
|
|
77
|
-
]);
|
|
78
|
-
const results = outcomes.map((outcome) => outcome.kind === "refused"
|
|
79
|
-
? { status: "rejected", reason: outcome.error }
|
|
80
|
-
: { status: "fulfilled", value: outcome.kind === "listing" ? outcome.data : null });
|
|
81
|
-
const [dirsResult, filesResult, linksResult] = results;
|
|
82
|
-
// A sub-listing that FAILED is not a sub-listing that was empty. The
|
|
83
|
-
// folders of a home root list while its files 500, and rendering the
|
|
84
|
-
// folders alone as the answer is the listing lying about the store
|
|
85
|
-
// (#462). What could not be read is named, and the caller decides
|
|
86
|
-
// what to do with a partial answer — it is never silently whole.
|
|
87
|
-
const unread = [];
|
|
88
|
-
const kinds = ['directories', 'files', 'links'];
|
|
89
|
-
results.forEach((settled, index) => {
|
|
90
|
-
const kind = kinds[index] ?? 'entries';
|
|
91
|
-
if (settled.status === 'rejected') {
|
|
92
|
-
const reason = settled.reason;
|
|
93
|
-
const message = reason instanceof Error ? reason.message : String(reason);
|
|
94
|
-
unread.push(`${kind} (${message})`);
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
const short = settled.value?.incomplete;
|
|
98
|
-
if (short !== undefined)
|
|
99
|
-
unread.push(`${kind} (${short.reason})`);
|
|
100
|
-
});
|
|
101
|
-
if (unread.length > 0) {
|
|
102
|
-
cumin_1.errorStack.stack_push('error', `Cannot fully list ${resolvedPath}: could not read ${unread.join(', ')}`);
|
|
103
|
-
}
|
|
104
|
-
// files_listAll returns null both for a failed folder resolution and for
|
|
105
|
-
// an existing folder whose collection is simply empty. When every
|
|
106
|
-
// sub-listing comes back empty-or-failed the two cases are
|
|
107
|
-
// indistinguishable here, so probe the parent listing: a missing folder
|
|
108
|
-
// must surface as an error, not render as an empty directory.
|
|
109
|
-
// Nothing came back from any of the three, and none of them refused:
|
|
110
|
-
// either the folder is empty or it is not there, and only the parent
|
|
111
|
-
// can say which.
|
|
112
|
-
const noneSucceeded = outcomes.every((outcome) => outcome.kind !== "listing");
|
|
113
|
-
if (noneSucceeded && resolvedPath !== "/") {
|
|
114
|
-
const dirExists = await path_checkIsDir(resolvedPath);
|
|
115
|
-
if (!dirExists.ok) {
|
|
116
|
-
// The probe itself failed: report the verification failure rather
|
|
117
|
-
// than claiming the folder is absent.
|
|
118
|
-
return (0, cumin_1.Err)();
|
|
119
|
-
}
|
|
120
|
-
if (!dirExists.value) {
|
|
121
|
-
cumin_1.errorStack.stack_push("error", `Cannot list ${resolvedPath}: No such file or directory`);
|
|
122
|
-
return (0, cumin_1.Err)();
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
const items = [];
|
|
126
|
-
const mapToItem = chrisRow_convertToItem;
|
|
127
|
-
if (dirsResult.status === "fulfilled" && dirsResult.value?.tableData) {
|
|
128
|
-
dirsResult.value.tableData.forEach((d) => items.push(mapToItem(d, "dir")));
|
|
129
|
-
}
|
|
130
|
-
if (filesResult.status === "fulfilled" && filesResult.value?.tableData) {
|
|
131
|
-
filesResult.value.tableData.forEach((f) => items.push(mapToItem(f, "file")));
|
|
132
|
-
}
|
|
133
|
-
if (linksResult.status === "fulfilled" && linksResult.value?.tableData) {
|
|
134
|
-
linksResult.value.tableData.forEach((l) => items.push(mapToItem(l, "link")));
|
|
135
|
-
}
|
|
136
|
-
// A directory listing is name-unique by definition; CUBE's links
|
|
137
|
-
// search can return the same row more than once (observed on /PUBLIC),
|
|
138
|
-
// so keep the first occurrence of each name.
|
|
139
|
-
const seen = new Set();
|
|
140
|
-
const unique = items.filter((item) => {
|
|
141
|
-
if (seen.has(item.name))
|
|
142
|
-
return false;
|
|
143
|
-
seen.add(item.name);
|
|
144
|
-
return true;
|
|
145
|
-
});
|
|
146
|
-
const sorted = (0, sort_js_1.vfsItems_sort)(unique, options?.sort, options?.reverse);
|
|
147
|
-
return (0, cumin_1.Ok)(sorted);
|
|
110
|
+
const outcomes = await Promise.all(LISTED_KINDS.map(([asset]) => (0, index_js_1.files_listOutcome)(fetchOpts, asset, resolvedPath)));
|
|
111
|
+
return listedOutcomes_answer(resolvedPath, outcomes, options) ?? await folderUnlisted_settle(resolvedPath, options);
|
|
148
112
|
}
|
|
149
113
|
catch (error) {
|
|
150
114
|
const msg = error instanceof Error ? error.message : String(error);
|
|
@@ -152,9 +116,17 @@ class NativeVfsProvider {
|
|
|
152
116
|
return (0, cumin_1.Err)();
|
|
153
117
|
}
|
|
154
118
|
}
|
|
155
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* Copies within CUBE, create-only (`path_copy`): the source read whole,
|
|
121
|
+
* the destination proved, and nothing written onto a name already held.
|
|
122
|
+
*
|
|
123
|
+
* @param src - The source's absolute path.
|
|
124
|
+
* @param dest - The destination's absolute path.
|
|
125
|
+
* @param options - Whether a folder may be copied.
|
|
126
|
+
* @returns Done, or why not.
|
|
127
|
+
*/
|
|
156
128
|
async cp(src, dest, options) {
|
|
157
|
-
return (0,
|
|
129
|
+
return (0, copy_js_1.path_copy)(src, dest, options);
|
|
158
130
|
}
|
|
159
131
|
/**
|
|
160
132
|
* What a path is in its parent folder: a folder, a file or a link, and its
|
|
@@ -207,26 +179,6 @@ class NativeVfsProvider {
|
|
|
207
179
|
}
|
|
208
180
|
return (0, cumin_1.Ok)(found);
|
|
209
181
|
}
|
|
210
|
-
/**
|
|
211
|
-
* The one thing a removal may act on, or why it may not: ENOENT when
|
|
212
|
-
* nothing holds the path, and a refusal when a folder and a file share
|
|
213
|
-
* it, since CUBE's delete of either damages the other's record and every
|
|
214
|
-
* listing of the parent fails after (CUBE #732).
|
|
215
|
-
*
|
|
216
|
-
* @param target - The path to remove.
|
|
217
|
-
* @returns The single holder, or the failure.
|
|
218
|
-
*/
|
|
219
|
-
async removable_find(target) {
|
|
220
|
-
const all = await this.entries_find(target);
|
|
221
|
-
if (!all.ok)
|
|
222
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
223
|
-
if (all.value.length === 0)
|
|
224
|
-
return (0, fond_1.vfs_fail)('ENOENT');
|
|
225
|
-
if (all.value.length > 1) {
|
|
226
|
-
return (0, fond_1.vfs_fail)('EPERM', `a folder and a file share ${target}, and removing either would damage the other in CUBE`);
|
|
227
|
-
}
|
|
228
|
-
return (0, fond_1.vfs_ok)(all.value[0]);
|
|
229
|
-
}
|
|
230
182
|
/**
|
|
231
183
|
* Why an operation on a path failed, once it has: ENOENT when the path
|
|
232
184
|
* is not there, the given errno for what is, EIO when its parent could
|
|
@@ -256,6 +208,39 @@ class NativeVfsProvider {
|
|
|
256
208
|
return (0, fond_1.vfs_ok)(content.value);
|
|
257
209
|
return this.failure_classify(target, (type) => (type === 'dir' ? 'EISDIR' : 'EIO'));
|
|
258
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* Proves that nothing in CUBE holds a path: its parent was listed whole,
|
|
213
|
+
* found fresh on the session's client as an act on the proof would find
|
|
214
|
+
* it, and no folder, file or link there has the name (`pathHolders_answer`).
|
|
215
|
+
* A listing that was refused, failed or came back short proves nothing.
|
|
216
|
+
*
|
|
217
|
+
* @param target - An absolute CUBE path.
|
|
218
|
+
* @returns True only on that proof.
|
|
219
|
+
*/
|
|
220
|
+
async absence_prove(target) {
|
|
221
|
+
const mark = cumin_1.errorStack.checkpoint_mark();
|
|
222
|
+
const answer = await freshAnswer_prove(target);
|
|
223
|
+
cumin_1.errorStack.checkpoint_drain(mark);
|
|
224
|
+
return answer?.kind === 'absent';
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Proves what holds a path in CUBE (`pathHolders_answer`), fresh on the
|
|
228
|
+
* session's client as the act it decides will prove it, never through the
|
|
229
|
+
* memo of folder lookups: one holder and its kind, several, or nothing; a
|
|
230
|
+
* look that could not be made whole is `EIO`, and a file on the way
|
|
231
|
+
* `ENOTDIR`.
|
|
232
|
+
*
|
|
233
|
+
* @param target - An absolute CUBE path.
|
|
234
|
+
* @returns The proof, or why none could be made.
|
|
235
|
+
*/
|
|
236
|
+
async holder_prove(target) {
|
|
237
|
+
const answer = await freshAnswer_prove(target);
|
|
238
|
+
if (answer === null)
|
|
239
|
+
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
240
|
+
if (answer.kind === 'error')
|
|
241
|
+
return (0, fond_1.vfs_failFromStack)(answer.notDirectory ? 'ENOTDIR' : 'EIO');
|
|
242
|
+
return (0, fond_1.vfs_ok)((0, proof_js_1.pathProof_convertToHolderProof)(answer));
|
|
243
|
+
}
|
|
259
244
|
/** @inheritdoc */
|
|
260
245
|
async readBinary(target) {
|
|
261
246
|
const bytes = await (0, index_js_1.fileContent_getBinary)(target);
|
|
@@ -263,279 +248,238 @@ class NativeVfsProvider {
|
|
|
263
248
|
return (0, fond_1.vfs_ok)(bytes.value);
|
|
264
249
|
return this.failure_classify(target, (type) => (type === 'dir' ? 'EISDIR' : 'EIO'));
|
|
265
250
|
}
|
|
266
|
-
/**
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
// files_touch replaces: CUBE's upload does not, so a file already there is removed first.
|
|
281
|
-
return (0, fond_1.vfsOutcome_convertFromBoolean)(await (0, index_js_1.files_touch)(target, content), 'EIO');
|
|
251
|
+
/**
|
|
252
|
+
* Writes a file whole (`file_place`): its parent proved a folder, then
|
|
253
|
+
* what holds the path proved on the same client; a file there replaced,
|
|
254
|
+
* or kept as it is when asked (`touch`); a folder, a link or several
|
|
255
|
+
* holders refused, and nothing written.
|
|
256
|
+
*
|
|
257
|
+
* @param target - The file's absolute path.
|
|
258
|
+
* @param content - The content.
|
|
259
|
+
* @param options - What becomes of a file already there.
|
|
260
|
+
* @returns Done, or why not (`ENOENT` no parent, `ENOTDIR`, `EISDIR`, `EPERM`, `EIO`).
|
|
261
|
+
*/
|
|
262
|
+
async write(target, content, options = {}) {
|
|
263
|
+
const placed = await (0, create_js_1.file_place)(target, content, { existing: options.existing ?? 'replace', parent: 'require' });
|
|
264
|
+
return placed.ok ? (0, fond_1.vfs_ok)(true) : placed;
|
|
282
265
|
}
|
|
283
|
-
/**
|
|
266
|
+
/**
|
|
267
|
+
* Makes one folder on proof that nothing holds the path and its parent is
|
|
268
|
+
* a folder (`path_mkdir`); CUBE would answer a folder already there with
|
|
269
|
+
* success, and a disk says `EEXIST`.
|
|
270
|
+
*
|
|
271
|
+
* @param target - The folder's absolute path.
|
|
272
|
+
* @returns Done, or why not.
|
|
273
|
+
*/
|
|
284
274
|
async mkdir(target) {
|
|
285
|
-
|
|
286
|
-
const there = await this.entry_find(target);
|
|
287
|
-
if (!there.ok)
|
|
288
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
289
|
-
if (there.value !== null)
|
|
290
|
-
return (0, fond_1.vfs_fail)('EEXIST');
|
|
291
|
-
const parent = await this.entry_find(path_1.default.posix.dirname(target));
|
|
292
|
-
if (!parent.ok)
|
|
293
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
294
|
-
if (parent.value === null)
|
|
295
|
-
return (0, fond_1.vfs_fail)('ENOENT');
|
|
296
|
-
if (parent.value.type !== 'dir')
|
|
297
|
-
return (0, fond_1.vfs_fail)('ENOTDIR');
|
|
298
|
-
return (0, fond_1.vfsOutcome_convertFromBoolean)(await (0, index_js_1.files_mkdir)(target, { cleared: true }), 'EIO');
|
|
275
|
+
return (0, create_js_1.path_mkdir)(target);
|
|
299
276
|
}
|
|
300
|
-
/**
|
|
277
|
+
/**
|
|
278
|
+
* Makes a folder and its missing parents in CUBE's one request, on proof
|
|
279
|
+
* that nothing holds the path and no file stands on the way
|
|
280
|
+
* (`path_mkdirTree`).
|
|
281
|
+
*
|
|
282
|
+
* @param target - The folder's absolute path.
|
|
283
|
+
* @returns Done, or why not.
|
|
284
|
+
*/
|
|
301
285
|
async mkdirTree(target) {
|
|
302
|
-
|
|
303
|
-
// would make them over a file too: the nearest thing holding the path
|
|
304
|
-
// or a parent decides first.
|
|
305
|
-
const first = await (0, index_js_1.folderPath_holder)(target);
|
|
306
|
-
if (!first.ok)
|
|
307
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
308
|
-
if (first.value?.atTarget === true)
|
|
309
|
-
return (0, fond_1.vfs_fail)('EEXIST');
|
|
310
|
-
if (first.value !== null && first.value.holder !== 'dir')
|
|
311
|
-
return (0, fond_1.vfs_fail)('ENOTDIR');
|
|
312
|
-
return (0, fond_1.vfsOutcome_convertFromBoolean)(await (0, index_js_1.files_mkdir)(target, { cleared: true }), 'EIO');
|
|
313
|
-
}
|
|
314
|
-
/** @inheritdoc */
|
|
315
|
-
async rmdir(target) {
|
|
316
|
-
const there = await this.removable_find(target);
|
|
317
|
-
if (!there.ok)
|
|
318
|
-
return there;
|
|
319
|
-
if (there.value.type !== 'dir')
|
|
320
|
-
return (0, fond_1.vfs_fail)('ENOTDIR');
|
|
321
|
-
const held = await this.list(target);
|
|
322
|
-
if (!held.ok)
|
|
323
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
324
|
-
if (held.value.length > 0)
|
|
325
|
-
return (0, fond_1.vfs_fail)('ENOTEMPTY');
|
|
326
|
-
if (!await (0, index_js_1.files_delete)(there.value.id, 'dirs', path_1.default.posix.dirname(target)))
|
|
327
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
328
|
-
return await this.folderGone_await(target);
|
|
329
|
-
}
|
|
330
|
-
/** @inheritdoc */
|
|
331
|
-
async rename(src, dest) {
|
|
332
|
-
const from = await this.entry_find(src);
|
|
333
|
-
if (!from.ok)
|
|
334
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
335
|
-
if (from.value === null)
|
|
336
|
-
return (0, fond_1.vfs_fail)('ENOENT');
|
|
337
|
-
const onto = await this.entry_find(dest);
|
|
338
|
-
if (!onto.ok)
|
|
339
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
340
|
-
// CUBE has no overwrite (docs/CUBE-gaps.adoc), and the request it would
|
|
341
|
-
// take leaves a row its own API cannot serve, which poisons every
|
|
342
|
-
// listing of that folder: refused here, by name.
|
|
343
|
-
if (onto.value !== null) {
|
|
344
|
-
return (0, fond_1.vfs_fail)('EEXIST', `Destination exists: ${dest} — mise cannot overwrite a file; remove it first`);
|
|
345
|
-
}
|
|
346
|
-
const parent = await this.entry_find(path_1.default.posix.dirname(dest));
|
|
347
|
-
if (!parent.ok)
|
|
348
|
-
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
349
|
-
if (parent.value === null)
|
|
350
|
-
return (0, fond_1.vfs_fail)('ENOENT');
|
|
351
|
-
if (parent.value.type !== 'dir')
|
|
352
|
-
return (0, fond_1.vfs_fail)('ENOTDIR');
|
|
353
|
-
return (0, fond_1.vfsOutcome_convertFromBoolean)(await (0, index_js_1.files_move)(src, dest), 'EIO');
|
|
354
|
-
}
|
|
355
|
-
/** @inheritdoc */
|
|
356
|
-
async rm(target) {
|
|
357
|
-
const there = await this.removable_find(target);
|
|
358
|
-
if (!there.ok)
|
|
359
|
-
return there;
|
|
360
|
-
if (there.value.type === 'dir')
|
|
361
|
-
return (0, fond_1.vfs_fail)('EISDIR');
|
|
362
|
-
const asset = there.value.type === 'link' ? 'links' : 'files';
|
|
363
|
-
return (0, fond_1.vfsOutcome_convertFromBoolean)(await (0, index_js_1.files_delete)(there.value.id, asset, path_1.default.posix.dirname(target)), 'EIO');
|
|
286
|
+
return (0, create_js_1.path_mkdirTree)(target);
|
|
364
287
|
}
|
|
365
|
-
/**
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
return await
|
|
288
|
+
/**
|
|
289
|
+
* Removes what a path holds, within a scope, on proof, by the holder's id
|
|
290
|
+
* or address, and waits to see it gone (`path_remove`).
|
|
291
|
+
*
|
|
292
|
+
* @param target - The path.
|
|
293
|
+
* @param scope - What the removal may take.
|
|
294
|
+
* @returns Done, or why not; `EINPROGRESS` when CUBE accepted the removal
|
|
295
|
+
* and it was not seen done.
|
|
296
|
+
*/
|
|
297
|
+
async removal_run(target, scope) {
|
|
298
|
+
return removal_convertToOutcome(await (0, removal_js_1.path_remove)(target, scope, this.removalWait));
|
|
376
299
|
}
|
|
377
300
|
/**
|
|
378
|
-
*
|
|
301
|
+
* Removes a folder that is proved to be a folder, alone at its path, and
|
|
302
|
+
* empty.
|
|
379
303
|
*
|
|
380
|
-
* CUBE
|
|
381
|
-
*
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
* it waits, a few seconds at most, for the parent to stop naming it.
|
|
304
|
+
* CUBE's delete of a folder takes everything in it, so an answer that only
|
|
305
|
+
* looks like "empty" is not enough: the proofs come from `files/proof`,
|
|
306
|
+
* where a listing refused, one that could not be made, or one cut short is
|
|
307
|
+
* a failure and nothing is deleted.
|
|
385
308
|
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
309
|
+
* One gap stays open: CUBE has no request that deletes a folder only if it
|
|
310
|
+
* is empty, so a child that arrives between the proof and the delete goes
|
|
311
|
+
* with the folder (docs/CUBE-gaps.adoc).
|
|
312
|
+
*
|
|
313
|
+
* @param target - The folder's path.
|
|
314
|
+
* @returns Done, or why not: `ENOENT`, `ENOTDIR`, `ENOTEMPTY`, `EPERM`
|
|
315
|
+
* when more than one thing holds the path, `EIO` when a proof failed,
|
|
316
|
+
* `EINPROGRESS` when the removal was accepted and not seen done.
|
|
389
317
|
*/
|
|
390
|
-
async
|
|
391
|
-
|
|
392
|
-
const name = path_1.default.posix.basename(target);
|
|
393
|
-
const deadline = Date.now() + timeoutMs;
|
|
394
|
-
for (;;) {
|
|
395
|
-
const mark = cumin_1.errorStack.checkpoint_mark();
|
|
396
|
-
const outcome = await (0, index_js_1.files_listOutcome)({ limit: 1000, offset: 0 }, 'dirs', parent);
|
|
397
|
-
cumin_1.errorStack.checkpoint_drain(mark);
|
|
398
|
-
const named = outcome.kind === 'listing' && (outcome.data.tableData ?? [])
|
|
399
|
-
.some((row) => chrisRow_convertToItem(row, 'dir').name === name);
|
|
400
|
-
if (!named)
|
|
401
|
-
return (0, fond_1.vfs_ok)(true);
|
|
402
|
-
if (Date.now() >= deadline) {
|
|
403
|
-
return (0, fond_1.vfs_fail)('EIO', `CUBE accepted the removal of ${target} but still lists it after ${Math.round(timeoutMs / 1000)}s`);
|
|
404
|
-
}
|
|
405
|
-
await new Promise((resolve) => { setTimeout(resolve, FOLDER_GONE_POLL_MS); });
|
|
406
|
-
}
|
|
318
|
+
async rmdir(target) {
|
|
319
|
+
return this.removal_run(target, 'emptyFolder');
|
|
407
320
|
}
|
|
408
321
|
/**
|
|
409
|
-
*
|
|
322
|
+
* Moves what holds a path (`path_move`, the one layer that names a
|
|
323
|
+
* move: the source and the destination proved, the final name chosen,
|
|
324
|
+
* the move by id, all on one client).
|
|
410
325
|
*
|
|
411
|
-
* @param src -
|
|
412
|
-
* @param dest -
|
|
413
|
-
* @param options -
|
|
326
|
+
* @param src - The path now.
|
|
327
|
+
* @param dest - The destination.
|
|
328
|
+
* @param options - mv's naming, when asked for.
|
|
329
|
+
* @returns Done, or why not.
|
|
414
330
|
*/
|
|
415
|
-
async
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
if (!destIsDir.ok) {
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
const destLooksDir = dest.endsWith("/");
|
|
430
|
-
const finalDest = (destIsDir.value || destLooksDir)
|
|
431
|
-
? path_1.default.posix.join(dest, path_1.default.posix.basename(src))
|
|
432
|
-
: dest;
|
|
433
|
-
// A write onto a path the store already holds leaves a row CUBE's own
|
|
434
|
-
// API cannot serve, and one such row makes every listing of that
|
|
435
|
-
// folder fail (docs/CUBE-gaps.adoc). The store has no overwrite, so
|
|
436
|
-
// this is refused by name rather than attempted.
|
|
437
|
-
if (!srcIsDir.value && await path_checkFileExists(finalDest)) {
|
|
438
|
-
cumin_1.errorStack.stack_push("error", `Destination exists: ${finalDest} — mise cannot overwrite a file; remove it first`);
|
|
439
|
-
return false;
|
|
440
|
-
}
|
|
441
|
-
if (options.recursive) {
|
|
442
|
-
return await (0, index_js_1.files_copyRecursively)(src, finalDest);
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
return await (0, index_js_1.files_copy)(src, finalDest);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
catch (error) {
|
|
449
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
450
|
-
cumin_1.errorStack.stack_push("error", `Native VFS copy failed: ${msg}`);
|
|
451
|
-
return false;
|
|
452
|
-
}
|
|
331
|
+
async rename(src, dest, options = {}) {
|
|
332
|
+
return (0, move_js_1.path_move)(src, dest, options);
|
|
333
|
+
}
|
|
334
|
+
/** @inheritdoc */
|
|
335
|
+
async rm(target) {
|
|
336
|
+
return this.removal_run(target, 'entry');
|
|
337
|
+
}
|
|
338
|
+
/** @inheritdoc */
|
|
339
|
+
async rmTree(target) {
|
|
340
|
+
// CUBE removes a folder with everything in it in one request.
|
|
341
|
+
return this.removal_run(target, 'tree');
|
|
453
342
|
}
|
|
454
343
|
}
|
|
455
344
|
exports.NativeVfsProvider = NativeVfsProvider;
|
|
456
345
|
/**
|
|
457
|
-
*
|
|
346
|
+
* What holds a path, proved fresh on the session's client bound for it.
|
|
458
347
|
*
|
|
459
|
-
*
|
|
460
|
-
*
|
|
348
|
+
* @param target - An absolute CUBE path.
|
|
349
|
+
* @returns The answer; null when there is no connection (the reason stacked).
|
|
350
|
+
*/
|
|
351
|
+
async function freshAnswer_prove(target) {
|
|
352
|
+
const bound = await cumin_1.chrisIO.holderClient_bind();
|
|
353
|
+
return bound.ok ? (0, proof_js_1.pathHolders_answer)(target, bound.value) : null;
|
|
354
|
+
}
|
|
355
|
+
/** The three listings a native folder is read by, in the order its rows are shown. */
|
|
356
|
+
const LISTED_KINDS = [['dirs', 'dir', 'directories'], ['files', 'file', 'files'], ['links', 'link', 'links']];
|
|
357
|
+
/**
|
|
358
|
+
* Every row the three listings gave, as listing items, each name once: a
|
|
359
|
+
* folder's listing is name-unique, and CUBE's links search can return a row
|
|
360
|
+
* more than once (observed on /PUBLIC).
|
|
461
361
|
*
|
|
462
|
-
* @param
|
|
463
|
-
* @returns
|
|
464
|
-
* probe itself could not answer.
|
|
362
|
+
* @param outcomes - The three listings, in {@link LISTED_KINDS}' order.
|
|
363
|
+
* @returns The items.
|
|
465
364
|
*/
|
|
466
|
-
|
|
467
|
-
const
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
365
|
+
function listedRows_collect(outcomes) {
|
|
366
|
+
const seen = new Set();
|
|
367
|
+
const items = [];
|
|
368
|
+
outcomes.forEach((outcome, index) => {
|
|
369
|
+
if (outcome.kind !== 'listing')
|
|
370
|
+
return;
|
|
371
|
+
const kind = LISTED_KINDS[index]?.[1] ?? 'file';
|
|
372
|
+
for (const row of outcome.data.tableData) {
|
|
373
|
+
const item = chrisRow_convertToItem(row, kind);
|
|
374
|
+
if (seen.has(item.name))
|
|
375
|
+
continue;
|
|
376
|
+
seen.add(item.name);
|
|
377
|
+
items.push(item);
|
|
473
378
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
return candidate === targetPath || path_1.default.posix.basename(candidate) === name;
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
catch {
|
|
480
|
-
// A probe that cannot answer counts the path as taken: the cost of
|
|
481
|
-
// guessing wrong is the operator's folder.
|
|
482
|
-
return true;
|
|
483
|
-
}
|
|
379
|
+
});
|
|
380
|
+
return items;
|
|
484
381
|
}
|
|
485
382
|
/**
|
|
486
|
-
*
|
|
383
|
+
* The listings that could not be read, named with why: refused, or cut
|
|
384
|
+
* short; and, beside rows the others gave, one that could not be made.
|
|
487
385
|
*
|
|
488
|
-
*
|
|
489
|
-
*
|
|
490
|
-
*
|
|
386
|
+
* @param outcomes - The three listings, in {@link LISTED_KINDS}' order.
|
|
387
|
+
* @param rowsRead - Whether another listing gave rows.
|
|
388
|
+
* @returns Each unread listing, as `files (reason)`.
|
|
389
|
+
*/
|
|
390
|
+
function listingsUnread_name(outcomes, rowsRead) {
|
|
391
|
+
const unread = [];
|
|
392
|
+
outcomes.forEach((outcome, index) => {
|
|
393
|
+
const word = LISTED_KINDS[index]?.[2] ?? 'entries';
|
|
394
|
+
if (outcome.kind === 'refused')
|
|
395
|
+
unread.push(`${word} (${outcome.error.message})`);
|
|
396
|
+
else if (outcome.kind === 'listing' && outcome.data.incomplete !== undefined)
|
|
397
|
+
unread.push(`${word} (${outcome.data.incomplete.reason})`);
|
|
398
|
+
else if (outcome.kind === 'missing' && rowsRead)
|
|
399
|
+
unread.push(`${word} (no listing could be made)`);
|
|
400
|
+
});
|
|
401
|
+
return unread;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* A folder's answer from its three listings: every row read, with what could
|
|
405
|
+
* not be read said beside them; Err when nothing was read and something
|
|
406
|
+
* failed; empty only when all three were read whole.
|
|
491
407
|
*
|
|
492
|
-
* @param
|
|
493
|
-
* @
|
|
494
|
-
*
|
|
408
|
+
* @param target - The folder's path, for the words.
|
|
409
|
+
* @param outcomes - The three listings, in {@link LISTED_KINDS}' order.
|
|
410
|
+
* @param options - Sorting parameters.
|
|
411
|
+
* @returns The answer; null when a listing could not be made and none failed (only a proof settles it).
|
|
495
412
|
*/
|
|
496
|
-
|
|
497
|
-
const
|
|
498
|
-
const
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
return (0, cumin_1.Ok)(
|
|
413
|
+
function listedOutcomes_answer(target, outcomes, options) {
|
|
414
|
+
const items = listedRows_collect(outcomes);
|
|
415
|
+
const unread = listingsUnread_name(outcomes, items.length > 0);
|
|
416
|
+
if (items.length > 0) {
|
|
417
|
+
if (unread.length > 0)
|
|
418
|
+
cumin_1.errorStack.stack_push('error', `Cannot fully list ${target}: could not read ${unread.join(', ')}`);
|
|
419
|
+
return (0, cumin_1.Ok)((0, sort_js_1.vfsItems_sort)(items, options?.sort, options?.reverse));
|
|
503
420
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
421
|
+
if (unread.length > 0) {
|
|
422
|
+
cumin_1.errorStack.stack_push('error', `Cannot list ${target}: could not read ${unread.join(', ')}`);
|
|
423
|
+
return (0, cumin_1.Err)();
|
|
424
|
+
}
|
|
425
|
+
return outcomes.every((outcome) => outcome.kind !== 'missing') ? (0, cumin_1.Ok)([]) : null;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Lists a folder opened fresh, by its id: each of its three listings read
|
|
429
|
+
* whole and asked, whatever another answered. One refused, or cut short by
|
|
430
|
+
* the server's own count, is said beside the rows the others gave; rows are
|
|
431
|
+
* never shown as the whole folder when they are not.
|
|
432
|
+
*
|
|
433
|
+
* @param target - The folder's path, for the words.
|
|
434
|
+
* @param folder - The folder, opened fresh.
|
|
435
|
+
* @param options - Sorting parameters.
|
|
436
|
+
* @returns The rows (what was not read stacked); Err when none were read and a listing failed.
|
|
437
|
+
*/
|
|
438
|
+
async function folderOpened_list(target, folder, options) {
|
|
439
|
+
const outcomes = [];
|
|
440
|
+
for (const [asset] of LISTED_KINDS) {
|
|
510
441
|
try {
|
|
511
|
-
|
|
512
|
-
return (0, cumin_1.Ok)(folder !== null && folder !== undefined);
|
|
442
|
+
outcomes.push({ kind: "listing", data: await folder.listing_readWhole(asset) });
|
|
513
443
|
}
|
|
514
|
-
catch {
|
|
515
|
-
|
|
444
|
+
catch (error) {
|
|
445
|
+
outcomes.push({ kind: "refused", error: error instanceof Error ? error : new Error(String(error)) });
|
|
516
446
|
}
|
|
517
447
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
448
|
+
return listedOutcomes_answer(`${target} (the folder is there)`, outcomes, options) ?? (0, cumin_1.Ok)([]);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Settles a path no listing could be made for, fresh on the session's
|
|
452
|
+
* client: the folder is opened first (a folder there is listed by its id,
|
|
453
|
+
* whatever the memo of lookups said), and only when none is found is its
|
|
454
|
+
* parent asked, through the whole proof of the path (CUBE's search can hide
|
|
455
|
+
* a shared folder its parent's listing shows). Only an absence proved there
|
|
456
|
+
* is "No such file or directory". Never through a cached listing or the
|
|
457
|
+
* memo of lookups.
|
|
458
|
+
*
|
|
459
|
+
* @param target - The path.
|
|
460
|
+
* @param options - Sorting parameters, for a folder found.
|
|
461
|
+
* @returns The rows of a folder found; else Err, the reason stacked.
|
|
462
|
+
*/
|
|
463
|
+
async function folderUnlisted_settle(target, options) {
|
|
464
|
+
const bound = await cumin_1.chrisIO.holderClient_bind();
|
|
465
|
+
if (!bound.ok) {
|
|
466
|
+
cumin_1.errorStack.stack_push('error', `Cannot list ${target}: there is no connection to CUBE`);
|
|
467
|
+
return (0, cumin_1.Err)();
|
|
534
468
|
}
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
469
|
+
const opened = await bound.value.folder_openFresh(target);
|
|
470
|
+
if (opened.kind === 'found')
|
|
471
|
+
return folderOpened_list(target, opened.folder, options);
|
|
472
|
+
if (opened.kind === 'refused') {
|
|
473
|
+
cumin_1.errorStack.stack_push('error', `Cannot list ${target}: ${opened.reason}`);
|
|
538
474
|
return (0, cumin_1.Err)();
|
|
539
475
|
}
|
|
476
|
+
const answer = await (0, proof_js_1.pathHolders_answer)(target, bound.value);
|
|
477
|
+
if (answer.kind === 'error')
|
|
478
|
+
return (0, cumin_1.Err)();
|
|
479
|
+
const folder = (answer.kind === 'held' && answer.holder.kind === 'dir') || (answer.kind === 'ambiguous' && answer.holders.some((holder) => holder.kind === 'dir'));
|
|
480
|
+
const why = answer.kind === 'absent' ? 'No such file or directory'
|
|
481
|
+
: folder ? 'its parent lists a folder there, and CUBE would not open it' : 'Not a directory';
|
|
482
|
+
cumin_1.errorStack.stack_push('error', `Cannot list ${target}: ${why}`);
|
|
483
|
+
return (0, cumin_1.Err)();
|
|
540
484
|
}
|
|
541
485
|
//# sourceMappingURL=native.js.map
|