@@ -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 ( / \. ( t a r | t g z | z i p ) $ / 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