coderaft 0.0.7 → 0.0.8

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.
Files changed (3) hide show
  1. package/code.tar.zst +0 -0
  2. package/package.json +1 -1
  3. package/tar.mjs +23 -1
package/code.tar.zst CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coderaft",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "repository": "pithings/coderaft",
5
5
  "bin": {
6
6
  "coderaft": "./dist/cli.mjs"
package/tar.mjs CHANGED
@@ -6,7 +6,15 @@
6
6
  // a full-buffer approach while matching or beating system tar in speed.
7
7
  // Supports USTAR, GNU long names (type "L"), pax headers, and symlinks.
8
8
 
9
- import { createReadStream, mkdirSync, openSync, writeSync, closeSync, symlinkSync } from "node:fs";
9
+ import {
10
+ copyFileSync,
11
+ createReadStream,
12
+ mkdirSync,
13
+ openSync,
14
+ writeSync,
15
+ closeSync,
16
+ symlinkSync,
17
+ } from "node:fs";
10
18
  import { dirname, join } from "node:path";
11
19
  import { createZstdDecompress } from "node:zlib";
12
20
 
@@ -28,6 +36,7 @@ export async function extractTarZst(archivePath, destDir) {
28
36
  let end = 0; // write cursor
29
37
 
30
38
  let gnuLongName = "";
39
+ let gnuLongLink = "";
31
40
  let paxPath = "";
32
41
  const createdDirs = new Set();
33
42
 
@@ -95,6 +104,13 @@ export async function extractTarZst(archivePath, destDir) {
95
104
  continue;
96
105
  }
97
106
 
107
+ if (typeflag === "K") {
108
+ // eslint-disable-next-line no-control-regex
109
+ gnuLongLink = pool.toString("utf8", dataStart, dataStart + size).replace(/\0+$/, "");
110
+ start += totalNeeded;
111
+ continue;
112
+ }
113
+
98
114
  if (typeflag === "x") {
99
115
  paxPath = parsePaxPath(pool.toString("utf8", dataStart, dataStart + size));
100
116
  start += totalNeeded;
@@ -107,7 +123,9 @@ export async function extractTarZst(archivePath, destDir) {
107
123
  }
108
124
 
109
125
  const name = gnuLongName || paxPath || readTarPath(pool, headerStart);
126
+ const longLink = gnuLongLink;
110
127
  gnuLongName = "";
128
+ gnuLongLink = "";
111
129
  paxPath = "";
112
130
 
113
131
  if (name) {
@@ -115,6 +133,10 @@ export async function extractTarZst(archivePath, destDir) {
115
133
 
116
134
  if (typeflag === "5" || name.endsWith("/")) {
117
135
  ensureDir(fullPath);
136
+ } else if (typeflag === "1") {
137
+ const linkname = longLink || readString(pool, headerStart + 157, 100);
138
+ ensureDir(dirname(fullPath));
139
+ copyFileSync(join(destDir, linkname), fullPath);
118
140
  } else if (typeflag === "2") {
119
141
  const linkname = readString(pool, headerStart + 157, 100);
120
142
  ensureDir(dirname(fullPath));