mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2026-01-05 00:02:55 +08:00
Fix upload progress bug
This commit is contained in:
parent
db1d01308c
commit
d89855bb90
5
packages/cache/src/cache.ts
vendored
5
packages/cache/src/cache.ts
vendored
@ -509,6 +509,10 @@ async function saveCacheV2(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the archive size in the options, will be used to display the upload
|
||||||
|
// progress
|
||||||
|
options.archiveSizeBytes = archiveFileSize
|
||||||
|
|
||||||
core.debug('Reserving Cache')
|
core.debug('Reserving Cache')
|
||||||
const version = utils.getCacheVersion(
|
const version = utils.getCacheVersion(
|
||||||
paths,
|
paths,
|
||||||
@ -561,7 +565,6 @@ async function saveCacheV2(
|
|||||||
} else {
|
} else {
|
||||||
core.warning(`Failed to save: ${typedError.message}`)
|
core.warning(`Failed to save: ${typedError.message}`)
|
||||||
}
|
}
|
||||||
throw error
|
|
||||||
} finally {
|
} finally {
|
||||||
// Try to delete the archive to save space
|
// Try to delete the archive to save space
|
||||||
try {
|
try {
|
||||||
|
|||||||
10
packages/cache/src/internal/uploadUtils.ts
vendored
10
packages/cache/src/internal/uploadUtils.ts
vendored
@ -126,11 +126,7 @@ export async function uploadCacheArchiveSDK(
|
|||||||
): Promise<BlobUploadCommonResponse> {
|
): Promise<BlobUploadCommonResponse> {
|
||||||
const blobClient: BlobClient = new BlobClient(signedUploadURL)
|
const blobClient: BlobClient = new BlobClient(signedUploadURL)
|
||||||
const blockBlobClient: BlockBlobClient = blobClient.getBlockBlobClient()
|
const blockBlobClient: BlockBlobClient = blobClient.getBlockBlobClient()
|
||||||
|
const uploadProgress = new UploadProgress(options?.archiveSizeBytes ?? 0)
|
||||||
const properties = await blobClient.getProperties()
|
|
||||||
const contentLength = properties.contentLength ?? -1
|
|
||||||
|
|
||||||
const uploadProgress = new UploadProgress(contentLength)
|
|
||||||
|
|
||||||
// Specify data transfer options
|
// Specify data transfer options
|
||||||
const uploadOptions: BlockBlobParallelUploadOptions = {
|
const uploadOptions: BlockBlobParallelUploadOptions = {
|
||||||
@ -161,7 +157,9 @@ export async function uploadCacheArchiveSDK(
|
|||||||
|
|
||||||
return response
|
return response
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.debug(`Error uploading cache archive: ${error}`)
|
core.warning(
|
||||||
|
`uploadCacheArchiveSDK: internal error uploading cache archive: ${error.message}`
|
||||||
|
)
|
||||||
throw error
|
throw error
|
||||||
} finally {
|
} finally {
|
||||||
uploadProgress.stopDisplayTimer()
|
uploadProgress.stopDisplayTimer()
|
||||||
|
|||||||
4
packages/cache/src/options.ts
vendored
4
packages/cache/src/options.ts
vendored
@ -24,6 +24,10 @@ export interface UploadOptions {
|
|||||||
* @default 32MB
|
* @default 32MB
|
||||||
*/
|
*/
|
||||||
uploadChunkSize?: number
|
uploadChunkSize?: number
|
||||||
|
/**
|
||||||
|
* Archive size in bytes
|
||||||
|
*/
|
||||||
|
archiveSizeBytes?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user