@aspectlylabs/mikka 0.0.201 → 0.0.203
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/capture-copy.mjs +26 -0
- package/cli.js +437 -245
- package/client.js +16 -6
- package/http-link.js +706 -692
- package/login.js +61 -53
- package/main.js +385 -197
- package/mikka-release-manifest.json +25 -20
- package/mikka.js +437 -245
- package/npm-shrinkwrap.json +2 -2
- package/package.json +2 -2
- package/paths.js +5 -4
- package/sbom.cdx.json +7 -7
package/capture-copy.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { closeSync, constants, openSync, readSync, rmSync, writeSync } from "node:fs"
|
|
2
|
+
|
|
3
|
+
/** Copy exactly the checked descriptor, never reopening its pathname. */
|
|
4
|
+
export function copyCaptureFd(source, destination, size) {
|
|
5
|
+
const out = openSync(destination, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | (constants.O_NOFOLLOW ?? 0), 0o600)
|
|
6
|
+
let ok = false
|
|
7
|
+
try {
|
|
8
|
+
const buffer = Buffer.allocUnsafe(Math.min(size, 64 * 1024))
|
|
9
|
+
let position = 0
|
|
10
|
+
while (position < size) {
|
|
11
|
+
const read = readSync(source, buffer, 0, Math.min(buffer.length, size - position), position)
|
|
12
|
+
if (read === 0) throw new Error("Capture changed while copying.")
|
|
13
|
+
let written = 0
|
|
14
|
+
while (written < read) {
|
|
15
|
+
const count = writeSync(out, buffer, written, read - written)
|
|
16
|
+
if (count === 0) throw new Error("Capture copy failed.")
|
|
17
|
+
written += count
|
|
18
|
+
}
|
|
19
|
+
position += read
|
|
20
|
+
}
|
|
21
|
+
ok = true
|
|
22
|
+
} finally {
|
|
23
|
+
closeSync(out)
|
|
24
|
+
if (!ok) rmSync(destination, { force: true })
|
|
25
|
+
}
|
|
26
|
+
}
|