@@ -192,13 +192,7 @@ export async function importActorProfile(
192
192
console ?: Pick < Console , 'log' | 'warn' | 'error' >
193
193
onError ?: ( error : Error , context : { fileName ?: string } ) => void
194
194
} = { }
195
- tarStream : Readable ,
196
- options : {
197
- console ?: Pick < Console , 'log' | 'warn' | 'error' >
198
- onError ?: ( error : Error , context : { fileName ?: string } ) => void
199
- } = { }
200
195
) : Promise < Record < string , any > > {
201
- const { console = undefined } = options
202
196
const { console = undefined } = options
203
197
const extract = tar . extract ( )
204
198
const result : Record < string , any > = { }
@@ -230,22 +224,15 @@ export async function importActorProfile(
230
224
if ( fileName . endsWith ( '.json' ) ) {
231
225
result [ fileName ] = JSON . parse ( content )
232
226
console ?. log ( 'Parsed JSON file successfully:' , fileName )
233
- console ?. log ( 'Parsed JSON file successfully:' , fileName )
234
227
} else if ( fileName . endsWith ( '.yaml' ) || fileName . endsWith ( '.yml' ) ) {
235
228
result [ fileName ] = YAML . parse ( content )
236
229
} else if ( fileName . endsWith ( '.csv' ) ) {
237
230
result [ fileName ] = content
238
231
} else {
239
232
console ?. warn ( `Unsupported file type: ${ fileName } , skipping...` )
240
- console ?. warn ( `Unsupported file type: ${ fileName } , skipping...` )
241
233
}
242
234
} catch ( error : any ) {
243
- const errorMessage = `Error processing file ${ fileName } : ${ error . message } `
244
- if ( onError ) {
245
- onError ( new Error ( errorMessage ) , { fileName } )
246
- } else {
247
- reject ( new Error ( errorMessage ) )
248
- }
235
+ next ( error )
249
236
} finally {
250
237
next ( ) // Always continue
251
238
}
@@ -260,19 +247,16 @@ export async function importActorProfile(
260
247
} )
261
248
262
249
extract . on ( 'finish' , ( ) => {
263
- console ?. log ( 'All files processed successfully.' )
264
250
console ?. log ( 'All files processed successfully.' )
265
251
resolve ( result )
266
252
} )
267
253
268
254
extract . on ( 'error' , ( error ) => {
269
- console ?. error ( 'Error during tar extraction:' , error . message )
270
255
console ?. error ( 'Error during tar extraction:' , error . message )
271
256
reject ( new Error ( 'Failed to extract tar file.' ) )
272
257
} )
273
258
274
259
tarStream . on ( 'error' , ( error ) => {
275
- console ?. error ( 'Error in tar stream:' , error . message )
276
260
console ?. error ( 'Error in tar stream:' , error . message )
277
261
reject ( new Error ( 'Failed to process tar stream.' ) )
278
262
} )
0 commit comments