@procedures/archive 0.59.0 → 0.59.1
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/CHANGELOG.md +22 -0
- package/dist/procedures/archive/create.d.ts.map +1 -1
- package/dist/procedures/archive/create.js +7 -2
- package/dist/procedures/archive/create.js.map +1 -1
- package/dist/procedures/archive/extract.d.ts.map +1 -1
- package/dist/procedures/archive/extract.js +7 -2
- package/dist/procedures/archive/extract.js.map +1 -1
- package/dist/procedures/archive/list.d.ts.map +1 -1
- package/dist/procedures/archive/list.js +7 -2
- package/dist/procedures/archive/list.js.map +1 -1
- package/dist/root.d.ts +8 -2
- package/dist/root.d.ts.map +1 -1
- package/dist/root.js +10 -2
- package/dist/root.js.map +1 -1
- package/package.json +3 -3
- package/src/procedures/archive/create.ts +8 -2
- package/src/procedures/archive/extract.ts +8 -2
- package/src/procedures/archive/list.ts +8 -2
- package/src/root.ts +11 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @procedures/archive
|
|
2
2
|
|
|
3
|
+
## 0.59.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- c0ecfe0: The check of a path in a root and the operation on the path start in one hold of the roots. Thus the operation reads the links that the check read, for the calls of this process.
|
|
8
|
+
|
|
9
|
+
- `fs.move`, `fs.copy`, `archive.extract` and each confined procedure that writes files or starts a process hold the roots alone. The other calls share the hold.
|
|
10
|
+
- The calls get the hold in the order that they came. A nested call starts in the hold of its caller.
|
|
11
|
+
- A call in a shared hold that starts a nested call that needs the hold alone gets an error. This nested call writes files, and its caller declares no file writes.
|
|
12
|
+
- `holdRoots()` and `RootHoldMode` of `@procedures/fs/root`, and `rootHoldOf()` of `@procedures/fs`, give the hold to other packages.
|
|
13
|
+
- `@procedures/fs` uses `rwLock()` of `@mark1russell7/collections`.
|
|
14
|
+
- Updated dependencies [425ea64]
|
|
15
|
+
- Updated dependencies [ea801cd]
|
|
16
|
+
- Updated dependencies [74ddeff]
|
|
17
|
+
- Updated dependencies [6513a83]
|
|
18
|
+
- Updated dependencies [8c69a74]
|
|
19
|
+
- Updated dependencies [74ddeff]
|
|
20
|
+
- Updated dependencies [c0ecfe0]
|
|
21
|
+
- Updated dependencies [6cc8f0e]
|
|
22
|
+
- @procedures/client@0.59.1
|
|
23
|
+
- @procedures/fs@0.59.1
|
|
24
|
+
|
|
3
25
|
## 0.59.0
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/procedures/archive/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAM/F,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAwB9E;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/procedures/archive/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAM/F,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAwB9E;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,EAAE,QAAQ,GAAE,eAA0C,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAG3I"}
|
|
@@ -14,7 +14,7 @@ import { dirname } from "node:path";
|
|
|
14
14
|
import { ArchiveError } from "../../errors.js";
|
|
15
15
|
import { DEFAULT_ARCHIVE_SETTINGS, formatOfName } from "../../format.js";
|
|
16
16
|
import { entryParts } from "../../paths.js";
|
|
17
|
-
import { placesOf } from "../../root.js";
|
|
17
|
+
import { inHold, placesOf } from "../../root.js";
|
|
18
18
|
import { createTar } from "../../tar.js";
|
|
19
19
|
import { folderNames, under, walk } from "../../walk.js";
|
|
20
20
|
import { writeZip } from "../../zip.js";
|
|
@@ -46,7 +46,12 @@ async function inputNames(input, places) {
|
|
|
46
46
|
/**
|
|
47
47
|
* Make a tar.gz or zip archive of a folder or of files
|
|
48
48
|
*/
|
|
49
|
-
export
|
|
49
|
+
export function archiveCreate(input, settings = DEFAULT_ARCHIVE_SETTINGS) {
|
|
50
|
+
// The check of the paths and the work start in one hold of the roots: it reads files and writes one archive file, and it makes no link
|
|
51
|
+
return inHold(settings.root, "shared", () => createInRoot(input, settings));
|
|
52
|
+
}
|
|
53
|
+
/** The work of `archiveCreate()`, in its hold of the roots. */
|
|
54
|
+
async function createInRoot(input, settings) {
|
|
50
55
|
const places = await placesOf(settings.root, ["archive", "create"]);
|
|
51
56
|
const output = await places.place(input.output);
|
|
52
57
|
const format = formatOfName(input.output, input.format);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/procedures/archive/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../src/procedures/archive/create.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,WA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E,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7F,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../src/procedures/archive/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAK/F,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAqDhF;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../../../src/procedures/archive/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAK/F,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAqDhF;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,EAAE,QAAQ,GAAE,eAA0C,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAG9I"}
|
|
@@ -15,7 +15,7 @@ import { lstat, mkdir, realpath, rm, symlink, unlink, utimes } from "node:fs/pro
|
|
|
15
15
|
import { dirname, join } from "node:path";
|
|
16
16
|
import { DEFAULT_ARCHIVE_SETTINGS, formatOfFile } from "../../format.js";
|
|
17
17
|
import { planExtract } from "../../paths.js";
|
|
18
|
-
import { isInside, outsideRoot, placesOf } from "../../root.js";
|
|
18
|
+
import { inHold, isInside, outsideRoot, placesOf } from "../../root.js";
|
|
19
19
|
import { extractTar, readTarEntries } from "../../tar.js";
|
|
20
20
|
import { extractZipFile, readZipDirectory, readZipLink } from "../../zip.js";
|
|
21
21
|
/** This function removes an old file or link at a path, so a new write does not follow it. */
|
|
@@ -73,7 +73,12 @@ function countsOf(planned) {
|
|
|
73
73
|
/**
|
|
74
74
|
* Extract a tar.gz or zip archive into a folder, with a check of each path
|
|
75
75
|
*/
|
|
76
|
-
export
|
|
76
|
+
export function archiveExtract(input, settings = DEFAULT_ARCHIVE_SETTINGS) {
|
|
77
|
+
// The check of the paths and the work start in one hold of the roots: it can make a link
|
|
78
|
+
return inHold(settings.root, "exclusive", () => extractInRoot(input, settings));
|
|
79
|
+
}
|
|
80
|
+
/** The work of `archiveExtract()`, in its hold of the roots. */
|
|
81
|
+
async function extractInRoot(input, settings) {
|
|
77
82
|
const places = await placesOf(settings.root, ["archive", "extract"]);
|
|
78
83
|
const archive = await places.place(input.archive);
|
|
79
84
|
const folder = await places.place(input.target);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../src/procedures/archive/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,WAAW,EAAoC,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../src/procedures/archive/extract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AACvF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,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AC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,MAAM,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjF,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/procedures/archive/list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI/F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvG,4EAA4E;AAC5E,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAyBzH;AAED;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../src/procedures/archive/list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAA0C,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAI/F,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvG,4EAA4E;AAC5E,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAyBzH;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,GAAE,eAA0C,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAGrI"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* module, the archive must be in the root.
|
|
7
7
|
*/
|
|
8
8
|
import { DEFAULT_ARCHIVE_SETTINGS, formatOfFile } from "../../format.js";
|
|
9
|
-
import { placesOf } from "../../root.js";
|
|
9
|
+
import { inHold, placesOf } from "../../root.js";
|
|
10
10
|
import { readTarEntries } from "../../tar.js";
|
|
11
11
|
import { readZipDirectory, readZipLink } from "../../zip.js";
|
|
12
12
|
/** The entries of an archive of a known format. `extract` uses them too. */
|
|
@@ -39,7 +39,12 @@ export async function readEntries(path, format, settings) {
|
|
|
39
39
|
/**
|
|
40
40
|
* The entries of a tar.gz or zip archive
|
|
41
41
|
*/
|
|
42
|
-
export
|
|
42
|
+
export function archiveList(input, settings = DEFAULT_ARCHIVE_SETTINGS) {
|
|
43
|
+
// The check of the paths and the work start in one hold of the roots: it reads one archive file
|
|
44
|
+
return inHold(settings.root, "shared", () => listInRoot(input, settings));
|
|
45
|
+
}
|
|
46
|
+
/** The work of `archiveList()`, in its hold of the roots. */
|
|
47
|
+
async function listInRoot(input, settings) {
|
|
43
48
|
const path = await (await placesOf(settings.root, ["archive", "list"])).place(input.archive);
|
|
44
49
|
const format = await formatOfFile(path, input.format);
|
|
45
50
|
const entries = await readEntries(path, format, { ...settings, maxBytes: Number.MAX_SAFE_INTEGER });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/procedures/archive/list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,wBAAwB,EAAE,YAAY,EAAwB,MAAM,iBAAiB,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../src/procedures/archive/list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA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EAAE,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC;IACpG,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACvH,CAAC"}
|
package/dist/root.d.ts
CHANGED
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
* lead a write or a `mkdir` out of the root.
|
|
12
12
|
*
|
|
13
13
|
* On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same. This
|
|
14
|
-
* file adds only `placesOf()`, the paths of one call of an archive procedure
|
|
14
|
+
* file adds only `placesOf()`, the paths of one call of an archive procedure, and `inHold()`.
|
|
15
15
|
*/
|
|
16
16
|
import type { ProcedurePath } from "@procedures/client";
|
|
17
|
-
import { type ResolvedRoot } from "@procedures/fs/root";
|
|
17
|
+
import { type ResolvedRoot, type RootHoldMode } from "@procedures/fs/root";
|
|
18
18
|
export { OUTSIDE_ROOT, inRoot, isInside, isOutsideRoot, outsideRoot, realPathIsInside, realPathOf, type ResolvedRoot } from "@procedures/fs/root";
|
|
19
19
|
/** This function gives the absolute path and the real path of a root of the archive procedures. The root must exist. */
|
|
20
20
|
export declare function resolveRoot(root: string): Promise<ResolvedRoot>;
|
|
@@ -29,6 +29,12 @@ export interface Places {
|
|
|
29
29
|
*/
|
|
30
30
|
place(path: string): Promise<string>;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* This function starts the work of one call in a hold of the roots (`holdRoots()` of
|
|
34
|
+
* `@procedures/fs/root`) when the module has a root. So the check of a path and its use read the
|
|
35
|
+
* same links. Without a root, the work starts with no hold.
|
|
36
|
+
*/
|
|
37
|
+
export declare function inHold<T>(root: string | undefined, mode: RootHoldMode, work: () => Promise<T>): Promise<T>;
|
|
32
38
|
/** This function gives the paths of one call. With a root, the root must exist when the call starts. */
|
|
33
39
|
export declare function placesOf(root: string | undefined, procedure: ProcedurePath): Promise<Places>;
|
|
34
40
|
//# sourceMappingURL=root.d.ts.map
|
package/dist/root.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAmD,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAE5H,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,UAAU,EAAE,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAElJ,wHAAwH;AACxH,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAE/D;AAED,4CAA4C;AAC5C,MAAM,WAAW,MAAM;IACrB,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACtC;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE1G;AAED,wGAAwG;AACxG,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAIlG"}
|
package/dist/root.js
CHANGED
|
@@ -11,15 +11,23 @@
|
|
|
11
11
|
* lead a write or a `mkdir` out of the root.
|
|
12
12
|
*
|
|
13
13
|
* On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same. This
|
|
14
|
-
* file adds only `placesOf()`, the paths of one call of an archive procedure
|
|
14
|
+
* file adds only `placesOf()`, the paths of one call of an archive procedure, and `inHold()`.
|
|
15
15
|
*/
|
|
16
16
|
import { resolve } from "node:path";
|
|
17
|
-
import { inRoot, resolveRoot as resolveFsRoot } from "@procedures/fs/root";
|
|
17
|
+
import { holdRoots, inRoot, resolveRoot as resolveFsRoot } from "@procedures/fs/root";
|
|
18
18
|
export { OUTSIDE_ROOT, inRoot, isInside, isOutsideRoot, outsideRoot, realPathIsInside, realPathOf } from "@procedures/fs/root";
|
|
19
19
|
/** This function gives the absolute path and the real path of a root of the archive procedures. The root must exist. */
|
|
20
20
|
export function resolveRoot(root) {
|
|
21
21
|
return resolveFsRoot(root, "the archive procedures");
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* This function starts the work of one call in a hold of the roots (`holdRoots()` of
|
|
25
|
+
* `@procedures/fs/root`) when the module has a root. So the check of a path and its use read the
|
|
26
|
+
* same links. Without a root, the work starts with no hold.
|
|
27
|
+
*/
|
|
28
|
+
export function inHold(root, mode, work) {
|
|
29
|
+
return root === undefined ? work() : holdRoots(mode, work);
|
|
30
|
+
}
|
|
23
31
|
/** This function gives the paths of one call. With a root, the root must exist when the call starts. */
|
|
24
32
|
export async function placesOf(root, procedure) {
|
|
25
33
|
if (root === undefined)
|
package/dist/root.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":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AAI,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC;AAChF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@procedures/archive",
|
|
4
|
-
"version": "0.59.
|
|
4
|
+
"version": "0.59.1",
|
|
5
5
|
"description": "Archives as procedures: make, list and extract tar.gz and zip, with a check of each path against zip slip and links out of the target.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"procedures",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"procedures": "./dist/register.js"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@procedures/client": "0.59.
|
|
71
|
-
"@procedures/fs": "0.59.
|
|
70
|
+
"@procedures/client": "0.59.1",
|
|
71
|
+
"@procedures/fs": "0.59.1",
|
|
72
72
|
"tar": "^7.5.0",
|
|
73
73
|
"zod": "^4.6.5"
|
|
74
74
|
},
|
|
@@ -15,7 +15,7 @@ import { dirname } from "node:path";
|
|
|
15
15
|
import { ArchiveError } from "../../errors.js";
|
|
16
16
|
import { DEFAULT_ARCHIVE_SETTINGS, formatOfName, type ArchiveSettings } from "../../format.js";
|
|
17
17
|
import { entryParts } from "../../paths.js";
|
|
18
|
-
import { placesOf, type Places } from "../../root.js";
|
|
18
|
+
import { inHold, placesOf, type Places } from "../../root.js";
|
|
19
19
|
import { createTar } from "../../tar.js";
|
|
20
20
|
import { folderNames, under, walk } from "../../walk.js";
|
|
21
21
|
import { writeZip, type ZipWriteEntry } from "../../zip.js";
|
|
@@ -46,7 +46,13 @@ async function inputNames(input: ArchiveCreateInput, places: Places): Promise<{
|
|
|
46
46
|
/**
|
|
47
47
|
* Make a tar.gz or zip archive of a folder or of files
|
|
48
48
|
*/
|
|
49
|
-
export
|
|
49
|
+
export function archiveCreate(input: ArchiveCreateInput, settings: ArchiveSettings = DEFAULT_ARCHIVE_SETTINGS): Promise<ArchiveCreateOutput> {
|
|
50
|
+
// The check of the paths and the work start in one hold of the roots: it reads files and writes one archive file, and it makes no link
|
|
51
|
+
return inHold(settings.root, "shared", () => createInRoot(input, settings));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The work of `archiveCreate()`, in its hold of the roots. */
|
|
55
|
+
async function createInRoot(input: ArchiveCreateInput, settings: ArchiveSettings): Promise<ArchiveCreateOutput> {
|
|
50
56
|
const places = await placesOf(settings.root, ["archive", "create"]);
|
|
51
57
|
const output = await places.place(input.output);
|
|
52
58
|
const format = formatOfName(input.output, input.format);
|
|
@@ -16,7 +16,7 @@ import { lstat, mkdir, realpath, rm, symlink, unlink, utimes } from "node:fs/pro
|
|
|
16
16
|
import { dirname, join } from "node:path";
|
|
17
17
|
import { DEFAULT_ARCHIVE_SETTINGS, formatOfFile, type ArchiveSettings } from "../../format.js";
|
|
18
18
|
import { planExtract, type PlannedEntry, type RawEntry } from "../../paths.js";
|
|
19
|
-
import { isInside, outsideRoot, placesOf } from "../../root.js";
|
|
19
|
+
import { inHold, isInside, outsideRoot, placesOf } from "../../root.js";
|
|
20
20
|
import { extractTar, readTarEntries } from "../../tar.js";
|
|
21
21
|
import { extractZipFile, readZipDirectory, readZipLink, type ZipEntry } from "../../zip.js";
|
|
22
22
|
import type { ArchiveExtractInput, ArchiveExtractOutput } from "../../types.js";
|
|
@@ -75,7 +75,13 @@ function countsOf(planned: readonly PlannedEntry[]): Pick<ArchiveExtractOutput,
|
|
|
75
75
|
/**
|
|
76
76
|
* Extract a tar.gz or zip archive into a folder, with a check of each path
|
|
77
77
|
*/
|
|
78
|
-
export
|
|
78
|
+
export function archiveExtract(input: ArchiveExtractInput, settings: ArchiveSettings = DEFAULT_ARCHIVE_SETTINGS): Promise<ArchiveExtractOutput> {
|
|
79
|
+
// The check of the paths and the work start in one hold of the roots: it can make a link
|
|
80
|
+
return inHold(settings.root, "exclusive", () => extractInRoot(input, settings));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The work of `archiveExtract()`, in its hold of the roots. */
|
|
84
|
+
async function extractInRoot(input: ArchiveExtractInput, settings: ArchiveSettings): Promise<ArchiveExtractOutput> {
|
|
79
85
|
const places = await placesOf(settings.root, ["archive", "extract"]);
|
|
80
86
|
const archive = await places.place(input.archive);
|
|
81
87
|
const folder = await places.place(input.target);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { DEFAULT_ARCHIVE_SETTINGS, formatOfFile, type ArchiveSettings } from "../../format.js";
|
|
10
|
-
import { placesOf } from "../../root.js";
|
|
10
|
+
import { inHold, placesOf } from "../../root.js";
|
|
11
11
|
import { readTarEntries } from "../../tar.js";
|
|
12
12
|
import { readZipDirectory, readZipLink } from "../../zip.js";
|
|
13
13
|
import type { ArchiveEntry, ArchiveFormat, ArchiveListInput, ArchiveListOutput } from "../../types.js";
|
|
@@ -43,7 +43,13 @@ export async function readEntries(path: string, format: ArchiveFormat, settings:
|
|
|
43
43
|
/**
|
|
44
44
|
* The entries of a tar.gz or zip archive
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export function archiveList(input: ArchiveListInput, settings: ArchiveSettings = DEFAULT_ARCHIVE_SETTINGS): Promise<ArchiveListOutput> {
|
|
47
|
+
// The check of the paths and the work start in one hold of the roots: it reads one archive file
|
|
48
|
+
return inHold(settings.root, "shared", () => listInRoot(input, settings));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The work of `archiveList()`, in its hold of the roots. */
|
|
52
|
+
async function listInRoot(input: ArchiveListInput, settings: ArchiveSettings): Promise<ArchiveListOutput> {
|
|
47
53
|
const path = await (await placesOf(settings.root, ["archive", "list"])).place(input.archive);
|
|
48
54
|
const format = await formatOfFile(path, input.format);
|
|
49
55
|
const entries = await readEntries(path, format, { ...settings, maxBytes: Number.MAX_SAFE_INTEGER });
|
package/src/root.ts
CHANGED
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
* lead a write or a `mkdir` out of the root.
|
|
12
12
|
*
|
|
13
13
|
* On Windows, the comparison ignores the case of the letters, and `/` and `\` are the same. This
|
|
14
|
-
* file adds only `placesOf()`, the paths of one call of an archive procedure
|
|
14
|
+
* file adds only `placesOf()`, the paths of one call of an archive procedure, and `inHold()`.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import { resolve } from "node:path";
|
|
18
18
|
import type { ProcedurePath } from "@procedures/client";
|
|
19
|
-
import { inRoot, resolveRoot as resolveFsRoot, type ResolvedRoot } from "@procedures/fs/root";
|
|
19
|
+
import { holdRoots, inRoot, resolveRoot as resolveFsRoot, type ResolvedRoot, type RootHoldMode } from "@procedures/fs/root";
|
|
20
20
|
|
|
21
21
|
export { OUTSIDE_ROOT, inRoot, isInside, isOutsideRoot, outsideRoot, realPathIsInside, realPathOf, type ResolvedRoot } from "@procedures/fs/root";
|
|
22
22
|
|
|
@@ -37,6 +37,15 @@ export interface Places {
|
|
|
37
37
|
place(path: string): Promise<string>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
/**
|
|
41
|
+
* This function starts the work of one call in a hold of the roots (`holdRoots()` of
|
|
42
|
+
* `@procedures/fs/root`) when the module has a root. So the check of a path and its use read the
|
|
43
|
+
* same links. Without a root, the work starts with no hold.
|
|
44
|
+
*/
|
|
45
|
+
export function inHold<T>(root: string | undefined, mode: RootHoldMode, work: () => Promise<T>): Promise<T> {
|
|
46
|
+
return root === undefined ? work() : holdRoots(mode, work);
|
|
47
|
+
}
|
|
48
|
+
|
|
40
49
|
/** This function gives the paths of one call. With a root, the root must exist when the call starts. */
|
|
41
50
|
export async function placesOf(root: string | undefined, procedure: ProcedurePath): Promise<Places> {
|
|
42
51
|
if (root === undefined) return { root: undefined, place: async (path) => resolve(path) };
|