@@ -1089,7 +1089,7 @@ group('sliceUploadFile() ', function () {
10891089 ) ;
10901090 } ) ;
10911091 test ( 'sliceUploadFile(),pauseTask(),restartTask()' , function ( done , assert ) {
1092- var cos = new COS ( {
1092+ var cos2 = new COS ( {
10931093 SecretId : config . SecretId ,
10941094 SecretKey : config . SecretKey ,
10951095 } ) ;
@@ -1100,25 +1100,26 @@ group('sliceUploadFile() ', function () {
11001100 var TaskId ;
11011101 var updateFn = function ( info ) {
11021102 const fileTask = info . list . find ( ( item ) => item . id === TaskId ) ;
1103+ console . log ( 'fileTask' , fileTask . state ) ;
11031104 if ( fileTask && paused && restarted ) {
11041105 if ( fileTask . state === 'success' ) {
1105- fs . unlinkSync ( filePath ) ;
1106- cos . off ( 'list-update' , updateFn ) ;
1106+ cos2 . off ( 'list-update' , updateFn ) ;
11071107 assert . ok ( 1 ) ;
11081108 done ( ) ;
1109+ fs . unlinkSync ( filePath ) ;
11091110 }
11101111 }
11111112 } ;
1112- cos . on ( 'list-update' , updateFn ) ;
1113- cos . abortUploadTask (
1113+ cos2 . on ( 'list-update' , updateFn ) ;
1114+ cos2 . abortUploadTask (
11141115 {
11151116 Bucket : config . Bucket ,
11161117 Region : config . Region ,
11171118 Key : filename ,
11181119 Level : 'file' ,
11191120 } ,
11201121 function ( err , data ) {
1121- cos . sliceUploadFile (
1122+ cos2 . sliceUploadFile (
11221123 {
11231124 Bucket : config . Bucket ,
11241125 Region : config . Region ,
@@ -1128,12 +1129,12 @@ group('sliceUploadFile() ', function () {
11281129 TaskId = taskId ;
11291130 } ,
11301131 onProgress : function ( info ) {
1131- if ( ! paused && info . percent >= 0.1 ) {
1132- cos . pauseTask ( TaskId ) ;
1132+ if ( ! paused && info . percent >= 0.2 ) {
1133+ cos2 . pauseTask ( TaskId ) ;
11331134 paused = true ;
11341135 setTimeout ( function ( ) {
11351136 restarted = true ;
1136- cos . restartTask ( TaskId ) ;
1137+ cos2 . restartTask ( TaskId ) ;
11371138 } , 100 ) ;
11381139 }
11391140 } ,
0 commit comments