@@ -6,14 +6,18 @@ const chalk = require('chalk');
66const prompts = require ( 'prompts' ) ;
77const path = require ( 'path' ) ;
88require ( 'winston-daily-rotate-file' ) ;
9- const logger = require ( '../lib/log' ) ;
109const ProgressBar = require ( 'progress' ) ;
10+ const BlueBirdPromise = require ( "bluebird" ) ;
11+
12+ const logger = require ( '../lib/log' ) ;
1113const { CHUNK_SIZE } = require ( '../lib/constants' ) ;
1214const { generateAuthorization, getRegistryInfo } = require ( '../lib/utils' ) ;
13- const { getExistChunks : _getExistChunks , uploadChunk : _uploadChunk , uploadSuccess : _uploadSuccess } = require ( '../lib/request' ) ;
14- const BlueBirdPromise = require ( "bluebird" ) ;
1515
16+ const { getExistChunks : _getExistChunks , uploadChunk : _uploadChunk , mergeAllChunks : _mergeAllChunks } = require ( '../lib/request' ) ;
17+
18+ const { withRetry } = require ( '../lib/withRetry' ) ;
1619const argv = require ( '../lib/argv' ) ;
20+
1721const { requestUrl, version } = getRegistryInfo ( argv . registry ) ;
1822
1923let Authorization = '' ;
@@ -106,15 +110,23 @@ const upload = async (filePath, parts = []) => {
106110 return ;
107111 }
108112
109- try {
110- const res = await _uploadSuccess ( requestUrl , {
113+
114+
115+
116+
117+ const merge = async ( ) =>
118+ await _mergeAllChunks ( requestUrl , {
111119 version,
112120 uploadId,
113121 fileSize,
114122 fileTag : md5
115123 } , {
116124 Authorization
117125 } ) ;
126+
127+
128+ try {
129+ const res = await withRetry ( merge , 3 , 500 ) ;
118130 if ( res . code ) {
119131 throw ( res . message ) ;
120132 }
0 commit comments