@@ -255,7 +255,15 @@ export async function downloadTool(
255
255
let stream = response . message . pipe ( file ) ;
256
256
stream . on ( 'close' , ( ) => {
257
257
tl . debug ( 'download complete' ) ;
258
- let fileSizeInBytes = _getFileSizeOnDisk ( destPath ) ;
258
+ let fileSizeInBytes : number ;
259
+ try {
260
+ fileSizeInBytes = _getFileSizeOnDisk ( destPath ) ;
261
+ }
262
+ catch ( err ) {
263
+ fileSizeInBytes = NaN ;
264
+ tl . warning ( `Unable to check file size of ${ destPath } due to error: ${ err . Message } ` ) ;
265
+ }
266
+
259
267
if ( ! isNaN ( fileSizeInBytes ) ) {
260
268
tl . debug ( `Downloaded file size: ${ fileSizeInBytes } bytes` ) ;
261
269
} else {
@@ -265,8 +273,7 @@ export async function downloadTool(
265
273
if ( ! isNaN ( downloadedContentLength ) &&
266
274
! isNaN ( fileSizeInBytes ) &&
267
275
fileSizeInBytes !== downloadedContentLength ) {
268
- let err : Error = new Error ( `Content-Length (${ downloadedContentLength } bytes) did not match downloaded file size (${ fileSizeInBytes } bytes).` ) ;
269
- reject ( err ) ;
276
+ tl . warning ( `Content-Length (${ downloadedContentLength } bytes) did not match downloaded file size (${ fileSizeInBytes } bytes).` ) ;
270
277
}
271
278
272
279
resolve ( destPath ) ;
@@ -308,15 +315,9 @@ function _getContentLengthOfDownloadedFile(response: httpm.HttpClientResponse):
308
315
* @param filePath the path to the file, saved to the disk
309
316
*/
310
317
function _getFileSizeOnDisk ( filePath : string ) : number {
311
- try {
312
- let fileStats = fs . statSync ( filePath ) ;
313
- let fileSizeInBytes = fileStats . size ;
314
- return fileSizeInBytes ;
315
- }
316
- catch ( err ) {
317
- tl . warning ( `Unable to find file size for ${ filePath } due to error: ${ err . Message } ` ) ;
318
- return NaN ;
319
- }
318
+ let fileStats = fs . statSync ( filePath ) ;
319
+ let fileSizeInBytes = fileStats . size ;
320
+ return fileSizeInBytes ;
320
321
}
321
322
322
323
//---------------------
0 commit comments