@@ -522,10 +522,17 @@ export class K8 {
522
522
const namespace = this . _getNamespace ( )
523
523
524
524
// get stat for source file in the container
525
- const entries = await this . listDir ( podName , containerName , srcPath )
525
+ let entries = await this . listDir ( podName , containerName , srcPath )
526
526
if ( entries . length !== 1 ) {
527
527
throw new FullstackTestingError ( `invalid source path: ${ srcPath } ` )
528
528
}
529
+ if ( entries [ 0 ] . name . indexOf ( ' -> ' ) > - 1 ) {
530
+ const redirectSrcPath = path . join ( path . dirname ( srcPath ) , entries [ 0 ] . name . substring ( entries [ 0 ] . name . indexOf ( ' -> ' ) + 4 ) )
531
+ entries = await this . listDir ( podName , containerName , redirectSrcPath )
532
+ if ( entries . length !== 1 ) {
533
+ throw new FullstackTestingError ( `invalid source path: ${ redirectSrcPath } ` )
534
+ }
535
+ }
529
536
const srcFileDesc = entries [ 0 ] // cache for later comparison after copy
530
537
531
538
if ( ! fs . existsSync ( destDir ) ) {
@@ -535,8 +542,8 @@ export class K8 {
535
542
try {
536
543
const srcFileSize = Number . parseInt ( srcFileDesc . size )
537
544
538
- const srcFile = path . basename ( srcPath )
539
- const srcDir = path . dirname ( srcPath )
545
+ const srcFile = path . basename ( entries [ 0 ] . name )
546
+ const srcDir = path . dirname ( entries [ 0 ] . name )
540
547
const destPath = path . join ( destDir , srcFile )
541
548
542
549
// download the tar file to a temp location
@@ -570,17 +577,21 @@ export class K8 {
570
577
return reject ( new FullstackTestingError ( `failed to copy because of error (${ code } ): ${ reason } ` ) )
571
578
}
572
579
573
- // extract the downloaded file
574
- await tar . x ( {
575
- file : tmpFile ,
576
- cwd : destDir
577
- } )
580
+ try {
581
+ // extract the downloaded file
582
+ await tar . x ( {
583
+ file : tmpFile ,
584
+ cwd : destDir
585
+ } )
578
586
579
- self . _deleteTempFile ( tmpFile )
587
+ self . _deleteTempFile ( tmpFile )
580
588
581
- const stat = fs . statSync ( destPath )
582
- if ( stat && stat . size === srcFileSize ) {
583
- return resolve ( true )
589
+ const stat = fs . statSync ( destPath )
590
+ if ( stat && stat . size === srcFileSize ) {
591
+ return resolve ( true )
592
+ }
593
+ } catch ( e ) {
594
+ return reject ( new FullstackTestingError ( `failed to extract file: ${ destPath } ` , e ) )
584
595
}
585
596
586
597
return reject ( new FullstackTestingError ( `failed to download file completely: ${ destPath } ` ) )
0 commit comments