@@ -77,6 +77,9 @@ interface ChunkHeader {
77
77
78
78
const CHUNK_HEADER_BYTES = 8 ;
79
79
80
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
81
+ const debug = ( ...args : unknown [ ] ) => { } ;
82
+
80
83
/**
81
84
* XetBlob is a blob implementation that fetches data directly from the Xet storage
82
85
*/
@@ -150,7 +153,7 @@ export class XetBlob extends Blob {
150
153
this . #reconstructionInfoPromise = ( async ( ) => {
151
154
const connParams = await getAccessToken ( this . repoId , this . accessToken , this . fetch , this . hubUrl ) ;
152
155
153
- // console.log (
156
+ // debug (
154
157
// `curl '${connParams.casUrl}/reconstruction/${this.hash}' -H 'Authorization: Bearer ${connParams.accessToken}'`
155
158
// );
156
159
@@ -217,15 +220,15 @@ export class XetBlob extends Blob {
217
220
const termRanges = rangeList . getRanges ( term . range . start , term . range . end ) ;
218
221
219
222
if ( termRanges . every ( ( range ) => range . data ) ) {
220
- console . log ( "all data available for term" , term . hash , readBytesToSkip ) ;
223
+ debug ( "all data available for term" , term . hash , readBytesToSkip ) ;
221
224
rangeLoop: for ( const range of termRanges ) {
222
225
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
223
226
for ( let chunk of range . data ! ) {
224
227
if ( chunk . length > maxBytes - totalBytesRead ) {
225
228
chunk = chunk . slice ( 0 , maxBytes - totalBytesRead ) ;
226
229
}
227
230
totalBytesRead += chunk . length ;
228
- console . log ( "yield" , chunk . length , "bytes" , "total read" , totalBytesRead ) ;
231
+ debug ( "yield" , chunk . length , "bytes" , "total read" , totalBytesRead ) ;
229
232
// The stream consumer can decide to transfer ownership of the chunk, so we need to return a clone
230
233
// if there's more than one range for the same term
231
234
yield range . refCount > 1 ? chunk . slice ( ) : chunk ;
@@ -250,9 +253,9 @@ export class XetBlob extends Blob {
250
253
) ;
251
254
}
252
255
253
- console . log ( "term" , term ) ;
254
- console . log ( "fetchinfo" , fetchInfo ) ;
255
- console . log ( "readBytesToSkip" , readBytesToSkip ) ;
256
+ debug ( "term" , term ) ;
257
+ debug ( "fetchinfo" , fetchInfo ) ;
258
+ debug ( "readBytesToSkip" , readBytesToSkip ) ;
256
259
257
260
let resp = await customFetch ( fetchInfo . url , {
258
261
headers : {
@@ -289,7 +292,7 @@ export class XetBlob extends Blob {
289
292
const result = await reader . read ( ) ;
290
293
done = result . done ;
291
294
292
- console . log ( "read" , result . value ?. length , "bytes" , "total read" , totalBytesRead , "toSkip" , readBytesToSkip ) ;
295
+ debug ( "read" , result . value ?. length , "bytes" , "total read" , totalBytesRead , "toSkip" , readBytesToSkip ) ;
293
296
294
297
if ( ! result . value ) {
295
298
continue ;
@@ -315,7 +318,7 @@ export class XetBlob extends Blob {
315
318
uncompressed_length : header . getUint8 ( 5 ) | ( header . getUint8 ( 6 ) << 8 ) | ( header . getUint8 ( 7 ) << 16 ) ,
316
319
} ;
317
320
318
- console . log ( "chunk header" , chunkHeader , "to skip" , readBytesToSkip ) ;
321
+ debug ( "chunk header" , chunkHeader , "to skip" , readBytesToSkip ) ;
319
322
320
323
if ( chunkHeader . version !== 0 ) {
321
324
throw new Error ( `Unsupported chunk version ${ chunkHeader . version } ` ) ;
@@ -377,18 +380,10 @@ export class XetBlob extends Blob {
377
380
}
378
381
379
382
if ( uncompressed . length ) {
380
- console . log (
381
- "yield" ,
382
- uncompressed . length ,
383
- "bytes" ,
384
- result . value . length ,
385
- "total read" ,
386
- totalBytesRead ,
387
- stored
388
- ) ;
383
+ debug ( "yield" , uncompressed . length , "bytes" , result . value . length , "total read" , totalBytesRead , stored ) ;
389
384
totalBytesRead += uncompressed . length ;
390
385
yield stored ? uncompressed . slice ( ) : uncompressed ;
391
- console . log (
386
+ debug (
392
387
"yielded" ,
393
388
uncompressed . length ,
394
389
"bytes" ,
@@ -405,7 +400,7 @@ export class XetBlob extends Blob {
405
400
}
406
401
}
407
402
408
- console . log ( "done" , done , "total read" , totalBytesRead ) ;
403
+ debug ( "done" , done , "total read" , totalBytesRead ) ;
409
404
410
405
// Release the reader
411
406
await reader . cancel ( ) ;
0 commit comments