@@ -260,19 +260,20 @@ function getUploadIdAndPartList(params, callback) {
260260 Size : ChunkSize
261261 } ) ;
262262 } else {
263- var chunkItem = util . fileSlice ( params . FilePath , start , end ) ;
264- util . getFileMd5 ( chunkItem , function ( err , md5 ) {
265- if ( err ) return callback ( err ) ;
266- var ETag = '"' + md5 + '"' ;
267- ETagMap [ PartNumber ] = ETag ;
268- FinishSliceCount += 1 ;
269- FinishSize += ChunkSize ;
270- callback ( err , {
271- PartNumber : PartNumber ,
272- ETag : ETag ,
273- Size : ChunkSize
263+ util . fileSlice ( params . FilePath , start , end , function ( chunkItem ) {
264+ util . getFileMd5 ( chunkItem , function ( err , md5 ) {
265+ if ( err ) return callback ( err ) ;
266+ var ETag = '"' + md5 + '"' ;
267+ ETagMap [ PartNumber ] = ETag ;
268+ FinishSliceCount += 1 ;
269+ FinishSize += ChunkSize ;
270+ callback ( err , {
271+ PartNumber : PartNumber ,
272+ ETag : ETag ,
273+ Size : ChunkSize
274+ } ) ;
275+ onHashProgress ( { loaded : FinishSize , total : FileSize } ) ;
274276 } ) ;
275- onHashProgress ( { loaded : FinishSize , total : FileSize } ) ;
276277 } ) ;
277278 }
278279 } ;
@@ -657,37 +658,39 @@ function uploadSliceItem(params, callback) {
657658 ContentLength = end - start ;
658659 }
659660
660- var md5Body = util . fileSlice ( FilePath , start , end ) ;
661- util . getFileMd5 ( md5Body , function ( err , md5 ) {
662- var contentMd5 = md5 ? util . binaryBase64 ( md5 ) : '' ;
663- var PartItem = UploadData . PartList [ PartNumber - 1 ] ;
664- Async . retry ( ChunkRetryTimes , function ( tryCallback ) {
665- if ( ! self . _isRunningTask ( TaskId ) ) return ;
666- var Body = util . fileSlice ( FilePath , start , end ) ;
667- self . multipartUpload ( {
668- TaskId : TaskId ,
669- Bucket : Bucket ,
670- Region : Region ,
671- Key : Key ,
672- ContentLength : ContentLength ,
673- PartNumber : PartNumber ,
674- UploadId : UploadData . UploadId ,
675- ServerSideEncryption : ServerSideEncryption ,
676- Body : Body ,
677- onProgress : params . onProgress ,
678- ContentMD5 : contentMd5 ,
661+ util . fileSlice ( FilePath , start , end , function ( md5Body ) {
662+ util . getFileMd5 ( md5Body , function ( err , md5 ) {
663+ var contentMd5 = md5 ? util . binaryBase64 ( md5 ) : '' ;
664+ var PartItem = UploadData . PartList [ PartNumber - 1 ] ;
665+ Async . retry ( ChunkRetryTimes , function ( tryCallback ) {
666+ if ( ! self . _isRunningTask ( TaskId ) ) return ;
667+ util . fileSlice ( FilePath , start , end , function ( Body ) {
668+ self . multipartUpload ( {
669+ TaskId : TaskId ,
670+ Bucket : Bucket ,
671+ Region : Region ,
672+ Key : Key ,
673+ ContentLength : ContentLength ,
674+ PartNumber : PartNumber ,
675+ UploadId : UploadData . UploadId ,
676+ ServerSideEncryption : ServerSideEncryption ,
677+ Body : Body ,
678+ onProgress : params . onProgress ,
679+ ContentMD5 : contentMd5 ,
680+ } , function ( err , data ) {
681+ if ( ! self . _isRunningTask ( TaskId ) ) return ;
682+ if ( err ) {
683+ return tryCallback ( err ) ;
684+ } else {
685+ PartItem . Uploaded = true ;
686+ return tryCallback ( null , data ) ;
687+ }
688+ } ) ;
689+ } ) ;
679690 } , function ( err , data ) {
680691 if ( ! self . _isRunningTask ( TaskId ) ) return ;
681- if ( err ) {
682- return tryCallback ( err ) ;
683- } else {
684- PartItem . Uploaded = true ;
685- return tryCallback ( null , data ) ;
686- }
692+ return callback ( err , data ) ;
687693 } ) ;
688- } , function ( err , data ) {
689- if ( ! self . _isRunningTask ( TaskId ) ) return ;
690- return callback ( err , data ) ;
691694 } ) ;
692695 } ) ;
693696}
@@ -973,7 +976,7 @@ function sliceCopyFile(params, callback) {
973976 var CopySliceSize = params . SliceSize === undefined ? self . options . CopySliceSize : params . SliceSize ;
974977 CopySliceSize = Math . max ( 0 , Math . min ( CopySliceSize , 5 * 1024 * 1024 * 1024 ) ) ;
975978
976- var ChunkSize = params . ChunkSize || this . options . ChunkSize ;
979+ var ChunkSize = params . ChunkSize || this . options . CopyChunkSize ;
977980 var ChunkParallel = this . options . CopyChunkParallelLimit ;
978981
979982 var FinishSize = 0 ;
0 commit comments