@@ -1651,6 +1651,7 @@ const io = __importStar(__webpack_require__(1));
16511651const fs = __importStar ( __webpack_require__ ( 747 ) ) ;
16521652const os = __importStar ( __webpack_require__ ( 87 ) ) ;
16531653const path = __importStar ( __webpack_require__ ( 622 ) ) ;
1654+ const util = __importStar ( __webpack_require__ ( 669 ) ) ;
16541655const uuidV4 = __importStar ( __webpack_require__ ( 826 ) ) ;
16551656const constants_1 = __webpack_require__ ( 694 ) ;
16561657// From https://github.com/actions/toolkit/blob/master/packages/tool-cache/src/tool-cache.ts#L23
@@ -1743,6 +1744,10 @@ function isValidEvent() {
17431744 return getSupportedEvents ( ) . includes ( githubEvent ) ;
17441745}
17451746exports . isValidEvent = isValidEvent ;
1747+ function unlinkFile ( path ) {
1748+ return util . promisify ( fs . unlink ) ( path ) ;
1749+ }
1750+ exports . unlinkFile = unlinkFile ;
17461751
17471752
17481753/***/ } ) ,
@@ -2831,18 +2836,29 @@ function run() {
28312836 try {
28322837 const cacheEntry = yield cacheHttpClient . getCacheEntry ( keys ) ;
28332838 if ( ! ( ( _a = cacheEntry ) === null || _a === void 0 ? void 0 : _a . archiveLocation ) ) {
2834- core . info ( `Cache not found for input keys: ${ keys . join ( ", " ) } . ` ) ;
2839+ core . info ( `Cache not found for input keys: ${ keys . join ( ", " ) } ` ) ;
28352840 return ;
28362841 }
28372842 const archivePath = path . join ( yield utils . createTempDirectory ( ) , "cache.tgz" ) ;
28382843 core . debug ( `Archive Path: ${ archivePath } ` ) ;
28392844 // Store the cache result
28402845 utils . setCacheState ( cacheEntry ) ;
2841- // Download the cache from the cache entry
2842- yield cacheHttpClient . downloadCache ( cacheEntry . archiveLocation , archivePath ) ;
2843- const archiveFileSize = utils . getArchiveFileSize ( archivePath ) ;
2844- core . info ( `Cache Size: ~${ Math . round ( archiveFileSize / ( 1024 * 1024 ) ) } MB (${ archiveFileSize } B)` ) ;
2845- yield tar_1 . extractTar ( archivePath , cachePath ) ;
2846+ try {
2847+ // Download the cache from the cache entry
2848+ yield cacheHttpClient . downloadCache ( cacheEntry . archiveLocation , archivePath ) ;
2849+ const archiveFileSize = utils . getArchiveFileSize ( archivePath ) ;
2850+ core . info ( `Cache Size: ~${ Math . round ( archiveFileSize / ( 1024 * 1024 ) ) } MB (${ archiveFileSize } B)` ) ;
2851+ yield tar_1 . extractTar ( archivePath , cachePath ) ;
2852+ }
2853+ finally {
2854+ // Try to delete the archive to save space
2855+ try {
2856+ yield utils . unlinkFile ( archivePath ) ;
2857+ }
2858+ catch ( error ) {
2859+ core . debug ( `Failed to delete archive: ${ error } ` ) ;
2860+ }
2861+ }
28462862 const isExactKeyMatch = utils . isExactKeyMatch ( primaryKey , cacheEntry ) ;
28472863 utils . setCacheHitOutput ( isExactKeyMatch ) ;
28482864 core . info ( `Cache restored from key: ${ cacheEntry && cacheEntry . cacheKey } ` ) ;
0 commit comments