Skip to content

Commit 66c7363

Browse files
(hotfix): make the tarball handling async
1 parent 2f894d5 commit 66c7363

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@
4444

4545
"repository": {
4646
"type": "git",
47-
"url": "git+https://github.com/collapsinghierarchy/noisytransfer-cli.git"
47+
"url": "git+https://github.com/collapsinghierarchy/noisytransfercli.git"
4848
},
4949
"bugs": {
50-
"url": "https://github.com/collapsinghierarchy/noisytransfer-cli/issues"
50+
"url": "https://github.com/collapsinghierarchy/noisytransfercli/issues"
5151
},
52-
"homepage": "https://github.com/collapsinghierarchy/noisytransfer-cli#readme",
52+
"homepage": "https://github.com/collapsinghierarchy/noisytransfercli#readme",
5353

5454
"scripts": {
5555
"clean": "rimraf dist .turbo .tsbuildinfo",

src/commands/send.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export async function run(paths, opts, ctx = {}) {
5454
// Build source + exact totalBytes
5555
let sourceStream;
5656
let totalBytes;
57+
let tarPromise = null;
5758

5859
if (useStdin) {
5960
sourceStream = process.stdin;
@@ -73,21 +74,14 @@ export async function run(paths, opts, ctx = {}) {
7374
sendNameHint = sanitizeFilename(deriveSendName(firstPath, opts) || "");
7475
} else {
7576
// multi-path (or a directory) → stream a tar we build on the fly
76-
const { pack, totalSizeTar } = await makeTarPack(paths, { exclude: opts.exclude || [] });
77-
sourceStream = pack;
78-
totalBytes = totalSizeTar;
77+
tarPromise = makeTarPack(paths, { exclude: opts.exclude || [] });
7978
sendNameHint = sanitizeFilename(deriveSendName(firstPath, opts) || "");
8079
// Set a stable .tar name unless user overrode with --name
8180
const base = path.basename(firstPath === "-" ? "stdin" : paths[0]);
8281
const stem = base.replace(/\.(tar|tgz|zip)$/i, "");
8382
sendNameHint = opts?.name ? String(opts.name) : `${stem}.tar`;
8483
getLogger().debug(`send: tarball name set to ${sendNameHint}`);
8584
}
86-
87-
if (!Number.isInteger(totalBytes) || totalBytes <= 0) {
88-
throw new Error(`internal: computed totalBytes invalid (${totalBytes})`);
89-
}
90-
9185
// Progress UI
9286
const t0 = Date.now();
9387
let lastTick = 0;
@@ -122,6 +116,17 @@ export async function run(paths, opts, ctx = {}) {
122116
getLogger().debug("send: RTC connected");
123117

124118
try {
119+
120+
if (tarPromise) {
121+
const { pack, totalSizeTar } = await tarPromise;
122+
sourceStream = pack;
123+
totalBytes = totalSizeTar;
124+
}
125+
126+
if (!Number.isInteger(totalBytes) || totalBytes <= 0) {
127+
throw new Error(`internal: computed totalBytes invalid (${totalBytes})`);
128+
}
129+
125130
if (opts.pq) {
126131
//const rtcAuth = wrapAuthDC(rtc, { sessionId, label: "pq-auth-sender" });
127132
await pqSend(rtc, {

0 commit comments

Comments
 (0)