@ -3270,19 +3270,18 @@ function downloadCache(archiveLocation, archivePath, options) {
exports . downloadCache = downloadCache ;
// Reserve Cache
function reserveCache ( key , paths , options ) {
var _a , _b ;
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
const httpClient = createHttpClient ( ) ;
const version = getCacheVersion ( paths , options === null || options === void 0 ? void 0 : options . compressionMethod ) ;
const reserveCacheRequest = {
key ,
version
version ,
cacheSize : options === null || options === void 0 ? void 0 : options . cacheSize
} ;
const response = yield requestUtils _1 . retryTypedResponse ( 'reserveCache' , ( ) => _ _awaiter ( this , void 0 , void 0 , function * ( ) {
return httpClient . postJson ( getCacheApiUrl ( 'caches' ) , reserveCacheRequest ) ;
} ) ) ;
console . log ( response ) ;
return ( _b = ( _a = response === null || response === void 0 ? void 0 : response . result ) === null || _a === void 0 ? void 0 : _a . cacheId ) !== null && _b !== void 0 ? _b : - 1 ;
return response ;
} ) ;
}
exports . reserveCache = reserveCache ;
@ -46427,18 +46426,12 @@ exports.restoreCache = restoreCache;
* @ returns number returns cacheId if the cache was saved successfully and throws an error if save fails
* /
function saveCache ( paths , key , options ) {
var _a , _b ;
return _ _awaiter ( this , void 0 , void 0 , function * ( ) {
checkPaths ( paths ) ;
checkKey ( key ) ;
const compressionMethod = yield utils . getCompressionMethod ( ) ;
core . debug ( 'Reserving Cache' ) ;
const cacheId = yield cacheHttpClient . reserveCache ( key , paths , {
compressionMethod
} ) ;
if ( cacheId === - 1 ) {
throw new ReserveCacheError ( ` Unable to reserve cache with key ${ key } , another job may be creating this cache. ` ) ;
}
core . debug ( ` Cache ID: ${ cacheId } ` ) ;
let cacheId = null ;
const cachePaths = yield utils . resolvePaths ( paths ) ;
core . debug ( 'Cache Paths:' ) ;
core . debug ( ` ${ JSON . stringify ( cachePaths ) } ` ) ;
@ -46450,12 +46443,25 @@ function saveCache(paths, key, options) {
if ( core . isDebug ( ) ) {
yield tar _1 . listTar ( archivePath , compressionMethod ) ;
}
const fileSizeLimit = 10 * 1024 * 1024 * 1024 ; // 10GB per repo limit
const archiveFileSize = utils . getArchiveFileSizeInBytes ( archivePath ) ;
core . debug ( ` File Size: ${ archiveFileSize } ` ) ;
if ( archiveFileSize > fileSizeLimit ) {
throw new Error ( ` Cache size of ~ ${ Math . round ( archiveFileSize / ( 1024 * 1024 ) ) } MB ( ${ archiveFileSize } B) is over the 10GB limit, not saving cache. ` ) ;
const cacheSize = archiveFileSize ;
core . debug ( 'Reserving Cache' ) ;
let reserveCacheResponse = yield cacheHttpClient . reserveCache ( key , paths , {
compressionMethod ,
cacheSize
} ) ;
console . log ( reserveCacheResponse ) ;
if ( ( reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse . statusCode ) === 400 ) {
throw new ReserveCacheError ( ` Cache size of ~ ${ Math . round ( archiveFileSize / ( 1024 * 1024 ) ) } MB ( ${ archiveFileSize } B) is over the data cap limit, not saving cache. ` ) ;
}
if ( ( _a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse . result ) === null || _a === void 0 ? void 0 : _a . cacheId ) {
cacheId = ( _b = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse . result ) === null || _b === void 0 ? void 0 : _b . cacheId ;
}
else {
throw new ReserveCacheError ( ` Unable to reserve cache with key ${ key } , another job may be creating this cache. ` ) ;
}
core . debug ( ` Cache ID: ${ cacheId } ` ) ;
core . debug ( ` Saving Cache (ID: ${ cacheId } ) ` ) ;
yield cacheHttpClient . saveCache ( cacheId , archivePath , options ) ;
}