hammerkit 2.1.0-next.19 → 2.1.0-next.20
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/dist/kubernetes/ensure-persistent-data.js +1 -1
- package/dist/kubernetes/sync-changes.js +322 -39
- package/dist/kubernetes/volumes.js +23 -1
- package/dist/server/executor.js +42 -26
- package/dist/server/run-worker.js +32 -54
- package/dist/server/sandbox-sync.js +269 -234
- package/dist/server/server.js +5 -6
- package/dist/utils/tar-files.js +52 -0
- package/package.json +1 -1
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tarFiles = void 0;
|
|
4
|
+
const tar_1 = require("tar");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const BLOCK = 512;
|
|
7
|
+
// the header of an entry, encoded in one block (node-tar cuts a long name to fit it)
|
|
8
|
+
function block(header) {
|
|
9
|
+
const buf = Buffer.alloc(BLOCK);
|
|
10
|
+
header.encode(buf, 0);
|
|
11
|
+
return buf;
|
|
12
|
+
}
|
|
13
|
+
// the bytes of `content` padded to whole blocks
|
|
14
|
+
function padded(content) {
|
|
15
|
+
const rest = content.length % BLOCK;
|
|
16
|
+
return rest === 0 ? content : Buffer.concat([content, Buffer.alloc(BLOCK - rest)]);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The archive of `files`: each at its path, with its mode, mtime and content. An empty list is
|
|
20
|
+
* an empty archive, the two blocks that end one.
|
|
21
|
+
*/
|
|
22
|
+
function tarFiles(files) {
|
|
23
|
+
const blocks = [];
|
|
24
|
+
for (const file of files) {
|
|
25
|
+
const mtime = file.mtime ?? new Date();
|
|
26
|
+
const header = new tar_1.Header({
|
|
27
|
+
path: file.path,
|
|
28
|
+
mode: file.mode,
|
|
29
|
+
size: file.content.length,
|
|
30
|
+
type: 'File',
|
|
31
|
+
mtime,
|
|
32
|
+
});
|
|
33
|
+
// encoding sets `needPax` when the path does not fit a ustar header
|
|
34
|
+
const head = block(header);
|
|
35
|
+
if (header.needPax) {
|
|
36
|
+
const body = Buffer.from(new tar_1.Pax({ path: file.path }, false).encodeBody());
|
|
37
|
+
const extended = new tar_1.Header({
|
|
38
|
+
path: `PaxHeader/${path_1.posix.basename(file.path)}`.slice(0, 100),
|
|
39
|
+
mode: 0o644,
|
|
40
|
+
size: body.length,
|
|
41
|
+
type: 'ExtendedHeader',
|
|
42
|
+
mtime,
|
|
43
|
+
});
|
|
44
|
+
blocks.push(block(extended), padded(body));
|
|
45
|
+
}
|
|
46
|
+
blocks.push(head, padded(file.content));
|
|
47
|
+
}
|
|
48
|
+
blocks.push(Buffer.alloc(BLOCK * 2));
|
|
49
|
+
return Buffer.concat(blocks);
|
|
50
|
+
}
|
|
51
|
+
exports.tarFiles = tarFiles;
|
|
52
|
+
//# sourceMappingURL=tar-files.js.map
|
package/package.json
CHANGED