@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
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The folder a copy goes into: proved one folder, or made when nothing holds it, on the copy's own client.
|
|
3
|
+
*
|
|
4
|
+
* A copy into a folder writes nothing until that folder is proved one
|
|
5
|
+
* folder, fresh, on the client the copy is bound to: nothing there, a file
|
|
6
|
+
* or a link, a name several holders share, or a proof that failed is no
|
|
7
|
+
* folder to copy into, and is refused with its errno and why. A folder that
|
|
8
|
+
* must be there to be copied into is proved again once what the copy writes
|
|
9
|
+
* has been read, before anything is written: one gone meanwhile would be
|
|
10
|
+
* made again by the write.
|
|
11
|
+
*
|
|
12
|
+
* Key components:
|
|
13
|
+
* - copyClient_bind: the session's client, bound for a copy.
|
|
14
|
+
* - folderNotMade_say: why a folder a copy asked for is not taken as the copy's.
|
|
15
|
+
* - copyFolder_proveOn, copyFolder_prove: prove a folder to copy into one folder.
|
|
16
|
+
* - copyFolder_settle: prove it, or make it when nothing holds it.
|
|
17
|
+
*
|
|
18
|
+
* Typical usage:
|
|
19
|
+
* ```ts
|
|
20
|
+
* const proved: VfsOutcome = await copyFolder_prove('/home/ada/results');
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Dependencies: the proofs of `./proof.js`, and cumin's `chrisIO` (the
|
|
24
|
+
* session's client, bound as a `HolderClient`). Paths are absolute CUBE paths.
|
|
25
|
+
*
|
|
26
|
+
* @module
|
|
27
|
+
*/
|
|
28
|
+
import { type FolderPosted, type HolderClient } from '@fnndsc/cumin';
|
|
29
|
+
import { type CpOptions, type VfsOutcome } from '@fnndsc/fond';
|
|
30
|
+
/**
|
|
31
|
+
* The session's client, bound for a copy.
|
|
32
|
+
*
|
|
33
|
+
* @param target - The destination, for the words.
|
|
34
|
+
* @returns The binding, or null (the reason stacked).
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* const acts: HolderClient | null = await copyClient_bind('/home/ada/results');
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare function copyClient_bind(target: string): Promise<HolderClient | null>;
|
|
42
|
+
/**
|
|
43
|
+
* Why a folder the copy asked for is not taken as the copy's.
|
|
44
|
+
*
|
|
45
|
+
* @param posted - What the post came to: a folder there already, or one there whose maker is not known.
|
|
46
|
+
* @returns The words, after a colon.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const words: string = folderNotMade_say('existed'); // ': a folder arrived there first'
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function folderNotMade_say(posted: FolderPosted): string;
|
|
54
|
+
/**
|
|
55
|
+
* Proves the folder a copy goes into one folder, fresh on the copy's client.
|
|
56
|
+
*
|
|
57
|
+
* @param acts - The copy's client.
|
|
58
|
+
* @param dest - The folder's absolute path.
|
|
59
|
+
* @returns Done on that proof; else why not, in words: nothing there, a
|
|
60
|
+
* file or a link, several holders, or a proof that failed.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const still: VfsOutcome = await copyFolder_proveOn(acts, '/home/ada/results');
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export declare function copyFolder_proveOn(acts: HolderClient, dest: string): Promise<VfsOutcome>;
|
|
68
|
+
/**
|
|
69
|
+
* Proves the folder a copy goes into one folder, fresh on the session's
|
|
70
|
+
* client bound for the copy.
|
|
71
|
+
*
|
|
72
|
+
* @param dest - The folder's absolute path.
|
|
73
|
+
* @returns Done on that proof; else why not, in words: nothing there, a
|
|
74
|
+
* file or a link, several holders, or a proof that failed.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```ts
|
|
78
|
+
* const proved: VfsOutcome = await copyFolder_prove('/home/ada/results');
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function copyFolder_prove(dest: string): Promise<VfsOutcome>;
|
|
82
|
+
/** How the folder a copy goes into came to be there: `held` already, or `made` for this copy. */
|
|
83
|
+
export type FolderSettled = 'held' | 'made';
|
|
84
|
+
/**
|
|
85
|
+
* Settles the folder a copy goes into, made when nothing holds it: one
|
|
86
|
+
* folder there is taken as it is; nothing there, directly in a folder
|
|
87
|
+
* proved one, is made create-only once the check of the path written allows
|
|
88
|
+
* it; anything else refuses, and nothing is made.
|
|
89
|
+
*
|
|
90
|
+
* @param dest - The folder's absolute path.
|
|
91
|
+
* @param options - The check asked of the folder before it is made.
|
|
92
|
+
* @returns Whether one folder was there already or was made for the copy;
|
|
93
|
+
* else why not: a file, several holders, no folder above it, a proof
|
|
94
|
+
* that failed, a check's refusal, or a folder that turned up before it
|
|
95
|
+
* was made (`EEXIST`).
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* ```ts
|
|
99
|
+
* const settled: VfsOutcome<FolderSettled> = await copyFolder_settle('/home/ada/results');
|
|
100
|
+
* const made: boolean = settled.ok && settled.value === 'made';
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function copyFolder_settle(dest: string, options?: Pick<CpOptions, 'finalPath_check'>): Promise<VfsOutcome<FolderSettled>>;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file The folder a copy goes into: proved one folder, or made when nothing holds it, on the copy's own client.
|
|
4
|
+
*
|
|
5
|
+
* A copy into a folder writes nothing until that folder is proved one
|
|
6
|
+
* folder, fresh, on the client the copy is bound to: nothing there, a file
|
|
7
|
+
* or a link, a name several holders share, or a proof that failed is no
|
|
8
|
+
* folder to copy into, and is refused with its errno and why. A folder that
|
|
9
|
+
* must be there to be copied into is proved again once what the copy writes
|
|
10
|
+
* has been read, before anything is written: one gone meanwhile would be
|
|
11
|
+
* made again by the write.
|
|
12
|
+
*
|
|
13
|
+
* Key components:
|
|
14
|
+
* - copyClient_bind: the session's client, bound for a copy.
|
|
15
|
+
* - folderNotMade_say: why a folder a copy asked for is not taken as the copy's.
|
|
16
|
+
* - copyFolder_proveOn, copyFolder_prove: prove a folder to copy into one folder.
|
|
17
|
+
* - copyFolder_settle: prove it, or make it when nothing holds it.
|
|
18
|
+
*
|
|
19
|
+
* Typical usage:
|
|
20
|
+
* ```ts
|
|
21
|
+
* const proved: VfsOutcome = await copyFolder_prove('/home/ada/results');
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Dependencies: the proofs of `./proof.js`, and cumin's `chrisIO` (the
|
|
25
|
+
* session's client, bound as a `HolderClient`). Paths are absolute CUBE paths.
|
|
26
|
+
*
|
|
27
|
+
* @module
|
|
28
|
+
*/
|
|
29
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
30
|
+
if (k2 === undefined) k2 = k;
|
|
31
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
32
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
33
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
34
|
+
}
|
|
35
|
+
Object.defineProperty(o, k2, desc);
|
|
36
|
+
}) : (function(o, m, k, k2) {
|
|
37
|
+
if (k2 === undefined) k2 = k;
|
|
38
|
+
o[k2] = m[k];
|
|
39
|
+
}));
|
|
40
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
41
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
42
|
+
}) : function(o, v) {
|
|
43
|
+
o["default"] = v;
|
|
44
|
+
});
|
|
45
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
46
|
+
var ownKeys = function(o) {
|
|
47
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
48
|
+
var ar = [];
|
|
49
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
50
|
+
return ar;
|
|
51
|
+
};
|
|
52
|
+
return ownKeys(o);
|
|
53
|
+
};
|
|
54
|
+
return function (mod) {
|
|
55
|
+
if (mod && mod.__esModule) return mod;
|
|
56
|
+
var result = {};
|
|
57
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
58
|
+
__setModuleDefault(result, mod);
|
|
59
|
+
return result;
|
|
60
|
+
};
|
|
61
|
+
})();
|
|
62
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
exports.copyClient_bind = copyClient_bind;
|
|
64
|
+
exports.folderNotMade_say = folderNotMade_say;
|
|
65
|
+
exports.copyFolder_proveOn = copyFolder_proveOn;
|
|
66
|
+
exports.copyFolder_prove = copyFolder_prove;
|
|
67
|
+
exports.copyFolder_settle = copyFolder_settle;
|
|
68
|
+
const path = __importStar(require("path"));
|
|
69
|
+
const cumin_1 = require("@fnndsc/cumin");
|
|
70
|
+
const fond_1 = require("@fnndsc/fond");
|
|
71
|
+
const proof_js_1 = require("./proof.js");
|
|
72
|
+
/**
|
|
73
|
+
* The session's client, bound for a copy.
|
|
74
|
+
*
|
|
75
|
+
* @param target - The destination, for the words.
|
|
76
|
+
* @returns The binding, or null (the reason stacked).
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* const acts: HolderClient | null = await copyClient_bind('/home/ada/results');
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
async function copyClient_bind(target) {
|
|
84
|
+
const bound = await cumin_1.chrisIO.holderClient_bind();
|
|
85
|
+
if (bound.ok)
|
|
86
|
+
return bound.value;
|
|
87
|
+
cumin_1.errorStack.stack_push('error', `Could not copy to ${target}: there is no connection to CUBE. Nothing was copied.`);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Why a folder the copy asked for is not taken as the copy's.
|
|
92
|
+
*
|
|
93
|
+
* @param posted - What the post came to: a folder there already, or one there whose maker is not known.
|
|
94
|
+
* @returns The words, after a colon.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* const words: string = folderNotMade_say('existed'); // ': a folder arrived there first'
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
function folderNotMade_say(posted) {
|
|
102
|
+
return posted === 'present'
|
|
103
|
+
? ': CUBE did not answer the request to make it, and a folder there now may not be the copy\'s; it is taken as held, and nothing is copied into it'
|
|
104
|
+
: ': a folder arrived there first';
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Whether a proof found one folder to copy into.
|
|
108
|
+
*
|
|
109
|
+
* @param dest - The folder's absolute path, for the words.
|
|
110
|
+
* @param there - Its proof.
|
|
111
|
+
* @returns Done for one folder; else `ENOENT`, `ENOTDIR`, `EPERM` or the proof's failure, and why.
|
|
112
|
+
*/
|
|
113
|
+
function copyFolder_judge(dest, there) {
|
|
114
|
+
if (there.kind === 'error')
|
|
115
|
+
return (0, fond_1.vfs_failFromStack)(there.notDirectory ? 'ENOTDIR' : 'EIO');
|
|
116
|
+
if (there.kind === 'held' && there.holder.kind === 'dir')
|
|
117
|
+
return (0, fond_1.vfs_ok)(true);
|
|
118
|
+
if (there.kind === 'absent')
|
|
119
|
+
return (0, fond_1.vfs_fail)('ENOENT', `${dest} is not a folder to copy into (nothing is there)`);
|
|
120
|
+
if (there.kind === 'ambiguous')
|
|
121
|
+
return (0, fond_1.vfs_fail)('EPERM', `${dest} is not a folder to copy into (${(0, proof_js_1.holders_describe)(there.holders)} share it)`);
|
|
122
|
+
return (0, fond_1.vfs_fail)('ENOTDIR', `${dest} is not a folder to copy into (a ${there.holder.kind} is there)`);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Proves the folder a copy goes into one folder, fresh on the copy's client.
|
|
126
|
+
*
|
|
127
|
+
* @param acts - The copy's client.
|
|
128
|
+
* @param dest - The folder's absolute path.
|
|
129
|
+
* @returns Done on that proof; else why not, in words: nothing there, a
|
|
130
|
+
* file or a link, several holders, or a proof that failed.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const still: VfsOutcome = await copyFolder_proveOn(acts, '/home/ada/results');
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
async function copyFolder_proveOn(acts, dest) {
|
|
138
|
+
return copyFolder_judge(dest, await (0, proof_js_1.pathHolders_answer)(dest, acts));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Proves the folder a copy goes into one folder, fresh on the session's
|
|
142
|
+
* client bound for the copy.
|
|
143
|
+
*
|
|
144
|
+
* @param dest - The folder's absolute path.
|
|
145
|
+
* @returns Done on that proof; else why not, in words: nothing there, a
|
|
146
|
+
* file or a link, several holders, or a proof that failed.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* ```ts
|
|
150
|
+
* const proved: VfsOutcome = await copyFolder_prove('/home/ada/results');
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
async function copyFolder_prove(dest) {
|
|
154
|
+
const acts = await copyClient_bind(dest);
|
|
155
|
+
if (acts === null)
|
|
156
|
+
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
157
|
+
return copyFolder_proveOn(acts, dest);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Settles the folder a copy goes into, made when nothing holds it: one
|
|
161
|
+
* folder there is taken as it is; nothing there, directly in a folder
|
|
162
|
+
* proved one, is made create-only once the check of the path written allows
|
|
163
|
+
* it; anything else refuses, and nothing is made.
|
|
164
|
+
*
|
|
165
|
+
* @param dest - The folder's absolute path.
|
|
166
|
+
* @param options - The check asked of the folder before it is made.
|
|
167
|
+
* @returns Whether one folder was there already or was made for the copy;
|
|
168
|
+
* else why not: a file, several holders, no folder above it, a proof
|
|
169
|
+
* that failed, a check's refusal, or a folder that turned up before it
|
|
170
|
+
* was made (`EEXIST`).
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```ts
|
|
174
|
+
* const settled: VfsOutcome<FolderSettled> = await copyFolder_settle('/home/ada/results');
|
|
175
|
+
* const made: boolean = settled.ok && settled.value === 'made';
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
async function copyFolder_settle(dest, options = {}) {
|
|
179
|
+
const acts = await copyClient_bind(dest);
|
|
180
|
+
if (acts === null)
|
|
181
|
+
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
182
|
+
const there = await (0, proof_js_1.pathHolders_answer)(dest, acts);
|
|
183
|
+
if (there.kind !== 'absent') {
|
|
184
|
+
const judged = copyFolder_judge(dest, there);
|
|
185
|
+
return judged.ok ? (0, fond_1.vfs_ok)('held') : judged;
|
|
186
|
+
}
|
|
187
|
+
const parent = path.posix.dirname(dest);
|
|
188
|
+
const above = await copyFolder_proveOn(acts, parent);
|
|
189
|
+
if (!above.ok)
|
|
190
|
+
return (0, fond_1.vfs_fail)(above.errno, `${dest} could not be made: ${above.reason ?? (0, fond_1.errno_words)(above.errno)}`);
|
|
191
|
+
const allowed = options.finalPath_check?.(dest) ?? (0, fond_1.vfs_ok)(true);
|
|
192
|
+
if (!allowed.ok)
|
|
193
|
+
return allowed;
|
|
194
|
+
const made = await acts.folder_create(dest);
|
|
195
|
+
if (!made.ok)
|
|
196
|
+
return (0, fond_1.vfs_failFromStack)('EIO');
|
|
197
|
+
return made.value === 'made' ? (0, fond_1.vfs_ok)('made') : (0, fond_1.vfs_fail)('EEXIST', `${dest} was proved free${folderNotMade_say(made.value)}`);
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=copyFolder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"copyFolder.js","sourceRoot":"","sources":["../../src/files/copyFolder.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBH,0CAKC;AAaD,8CAIC;AA8BD,gDAEC;AAeD,4CAIC;AAwBD,8CAgBC;AAnID,2CAA6B;AAE7B,yCAAuG;AACvG,uCAAiH;AAEjH,yCAAmF;AAEnF;;;;;;;;;;GAUG;AACI,KAAK,UAAU,eAAe,CAAC,MAAc;IAClD,MAAM,KAAK,GAAyB,MAAM,eAAO,CAAC,iBAAiB,EAAE,CAAC;IACtE,IAAI,KAAK,CAAC,EAAE;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC;IACjC,kBAAU,CAAC,UAAU,CAAC,OAAO,EAAE,qBAAqB,MAAM,uDAAuD,CAAC,CAAC;IACnH,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,iBAAiB,CAAC,MA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Aa,CAAC,IAAI,CAAC,CAAC;IAClE,IAAI,CAAC,IAAI,CAAC,EAAE;QAAE,OAAO,IAAA,wBAAiB,EAAC,KAAK,CAAC,CAAC;IAC9C,OAAO,IAAI,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAA,aAAM,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAA,eAAQ,EAAC,QAAQ,EAAE,GAAG,IAAI,mBAAmB,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAChI,CAAC"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Making what is not there yet, on proof that nothing holds its name.
|
|
3
|
+
*
|
|
4
|
+
* A folder is made, and a file is stored, only once a whole proof of the
|
|
5
|
+
* path says nothing holds it (`pathHolders_answer`, made fresh on the one
|
|
6
|
+
* client the act is bound to). A proof that could not be made is never
|
|
7
|
+
* read as a free name. A file already there is replaced, kept, or refused,
|
|
8
|
+
* as the caller asked (`file_store` of `./replace.js`), and a folder or
|
|
9
|
+
* several holders at the name refuse the write.
|
|
10
|
+
*
|
|
11
|
+
* CUBE makes a folder's missing parents with it, in one request; before it
|
|
12
|
+
* is asked, every folder on the way is proved, up to the root: each missing
|
|
13
|
+
* one absent, and every one that is there exactly one folder, the parent
|
|
14
|
+
* already there included. A folder already there is taken as one (by
|
|
15
|
+
* `files_mkdir`, as a placed write's parent, as `mkdir`'s parent) only on
|
|
16
|
+
* the same proof of the way above it. A file met on the way is `ENOTDIR`; a folder and
|
|
17
|
+
* a file (or two of either) sharing a name on the way is `EPERM`, and
|
|
18
|
+
* nothing is made. A path already held is `EEXIST`, carrying what the proof
|
|
19
|
+
* found there (`vfs_failHeld`). A post whose answer said nothing, with a
|
|
20
|
+
* folder found there after, is a folder there whose maker is not known:
|
|
21
|
+
* the act succeeds and says so (a warning), never claiming it made it.
|
|
22
|
+
*
|
|
23
|
+
* Key components:
|
|
24
|
+
* - files_mkdir: make a folder (and its parents) unless something else holds it.
|
|
25
|
+
* - files_create: store content at a path nothing holds (create-only).
|
|
26
|
+
* - files_touch: make a file, or leave one already there as it is; with content, write it.
|
|
27
|
+
* - file_place: store content with its parent proved (made, when asked), a file there replaced, kept or refused.
|
|
28
|
+
* - path_mkdir / path_mkdirTree: the native mount's `mkdir` and `mkdir -p`.
|
|
29
|
+
*
|
|
30
|
+
* Typical usage:
|
|
31
|
+
* ```ts
|
|
32
|
+
* const made: boolean = await files_mkdir('/home/ada/new/deeper');
|
|
33
|
+
* const placed: VfsOutcome<PlaceReceipt> = await file_place('/home/ada/out/q.csv', new Blob([csv]), { existing: 'refuse', parent: 'make' });
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* Dependencies: the proofs of `./proof.js` and `./move.js`, the proved
|
|
37
|
+
* write of `./replace.js`, and cumin's `chrisIO` (the session's client,
|
|
38
|
+
* bound as a `HolderClient`: a folder made, an upload). Paths are absolute
|
|
39
|
+
* CUBE paths; one written without its leading slash is read from the root.
|
|
40
|
+
*
|
|
41
|
+
* @module
|
|
42
|
+
*/
|
|
43
|
+
import { type VfsOutcome } from '@fnndsc/fond';
|
|
44
|
+
import { type FileAtPath, type StoreDone } from './replace.js';
|
|
45
|
+
/**
|
|
46
|
+
* What a placed write came to: what became of the file, and the folder made
|
|
47
|
+
* for it, when one was.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const receipt: PlaceReceipt = { done: 'created', created: '/home/ada/out' };
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export interface PlaceReceipt {
|
|
55
|
+
/** What became of the file. */
|
|
56
|
+
readonly done: StoreDone;
|
|
57
|
+
/** The parent folder made for it; null when it was there already. */
|
|
58
|
+
readonly created: string | null;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* How {@link file_place} treats what is at the path and above it.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const options: PlaceOptions = { existing: 'replace', parent: 'require' };
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export interface PlaceOptions {
|
|
69
|
+
/** What becomes of a file already at the path. */
|
|
70
|
+
readonly existing: FileAtPath;
|
|
71
|
+
/** `require` a parent folder that is there (`ENOENT` otherwise), or `make` it when nothing holds it. */
|
|
72
|
+
readonly parent: 'require' | 'make';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Makes one folder, its parent a folder that is there (`mkdir`): on proof
|
|
76
|
+
* that nothing holds the path, and that its parent is a folder.
|
|
77
|
+
*
|
|
78
|
+
* @param target - The folder's absolute path.
|
|
79
|
+
* @returns Done (`present` when CUBE did not answer and the folder is
|
|
80
|
+
* there, its maker unknown), or why not (`EEXIST` anything there,
|
|
81
|
+
* `ENOENT` no parent, `ENOTDIR` a file on the way, `EPERM`, `EIO`).
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* const made: VfsOutcome = await path_mkdir('/home/ada/new');
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare function path_mkdir(target: string): Promise<VfsOutcome>;
|
|
89
|
+
/**
|
|
90
|
+
* Makes a folder and its missing parents (`mkdir -p`), in CUBE's one
|
|
91
|
+
* request: on proof that nothing holds the path, and that every folder on
|
|
92
|
+
* the way is one folder or proved absent ({@link treeWay_prove}). A path
|
|
93
|
+
* already held is said only once the way to it is proved too, since `-p`
|
|
94
|
+
* takes a folder there as done.
|
|
95
|
+
*
|
|
96
|
+
* @param target - The folder's absolute path.
|
|
97
|
+
* @returns Done (`present` when CUBE did not answer and the folder is
|
|
98
|
+
* there, its maker unknown), or why not (`EEXIST` anything there,
|
|
99
|
+
* carrying what holds it, null when CUBE said a folder arrived; `ENOTDIR`
|
|
100
|
+
* a file on the way, `EPERM` twins on the way, `EIO`).
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```ts
|
|
104
|
+
* const made: VfsOutcome = await path_mkdirTree('/home/ada/new/deeper/still');
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
107
|
+
export declare function path_mkdirTree(target: string): Promise<VfsOutcome>;
|
|
108
|
+
/**
|
|
109
|
+
* Makes a folder at a path, and its missing parents, unless something other
|
|
110
|
+
* than a folder holds it: a folder already there is a success, as CUBE
|
|
111
|
+
* calls it; a file or a link there, several holders, a file above it, a
|
|
112
|
+
* name on the way that several things share, or a path that could not be
|
|
113
|
+
* proved is not, and nothing is made.
|
|
114
|
+
*
|
|
115
|
+
* @param folderPath - The folder's CUBE path.
|
|
116
|
+
* @returns True when a folder is at the path; false otherwise, with the
|
|
117
|
+
* reason on the error stack.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```ts
|
|
121
|
+
* const made: boolean = await files_mkdir('/home/ada/new');
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export declare function files_mkdir(folderPath: string): Promise<boolean>;
|
|
125
|
+
/**
|
|
126
|
+
* Stores content at a path nothing holds, create-only: a file already
|
|
127
|
+
* there, a folder, several holders, or a path that could not be proved
|
|
128
|
+
* free, and nothing is written.
|
|
129
|
+
*
|
|
130
|
+
* @param content - The content (text, bytes, or a Blob).
|
|
131
|
+
* @param pathStr - The file's CUBE path.
|
|
132
|
+
* @returns True when the path holds the content; false otherwise, with the
|
|
133
|
+
* reason on the error stack.
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```ts
|
|
137
|
+
* const created: boolean = await files_create('hello', '/home/ada/hello.txt');
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare function files_create(content: string | Buffer | Blob, pathStr: string): Promise<boolean>;
|
|
141
|
+
/**
|
|
142
|
+
* Makes a file (`touch`): a file already at the path is left as it is,
|
|
143
|
+
* and a missing one is made empty. With content, the file is written whole
|
|
144
|
+
* ({@link file_write}): made, or its content replaced. A folder, a link or
|
|
145
|
+
* several holders at the path, or a path that could not be proved, and
|
|
146
|
+
* nothing is written. A projection's file (a feed's note under /proc) is
|
|
147
|
+
* written through the projection that owns it, and takes text.
|
|
148
|
+
*
|
|
149
|
+
* @param written - The CUBE path; one written without its leading slash is
|
|
150
|
+
* read from the root.
|
|
151
|
+
* @param content - The content to write, when there is any.
|
|
152
|
+
* @returns True when done; false otherwise, with the reason on the error stack.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* const touched: boolean = await files_touch('/home/ada/notes.txt');
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
export declare function files_touch(written: string, content?: string | Buffer | Blob): Promise<boolean>;
|
|
160
|
+
/**
|
|
161
|
+
* Stores content at a path, its parent proved a folder first (or made, when
|
|
162
|
+
* asked and nothing holds it), and a file already at the path replaced,
|
|
163
|
+
* kept or refused, as asked. Every proof and act goes to one client, the
|
|
164
|
+
* session's when the write began.
|
|
165
|
+
*
|
|
166
|
+
* @param written - The CUBE path; one written without its leading slash is read from the root.
|
|
167
|
+
* @param content - The content.
|
|
168
|
+
* @param options - What becomes of a file there, and of a missing parent.
|
|
169
|
+
* @returns What was done and the folder made, or why not (`ENOENT` no
|
|
170
|
+
* parent, `ENOTDIR`, `EEXIST` a file refused, `EISDIR`, `EPERM`, `EIO`),
|
|
171
|
+
* the write's own reason when it gave one.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const placed: VfsOutcome<PlaceReceipt> = await file_place('/home/ada/out/q.csv', new Blob([csv]), { existing: 'refuse', parent: 'make' });
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
export declare function file_place(written: string, content: string | Buffer | Blob, options: PlaceOptions): Promise<VfsOutcome<PlaceReceipt>>;
|