@@ -64,8 +64,12 @@ export class Cache {
6464
6565 if ( ! this . ghaNoCache && cache . isFeatureAvailable ( ) ) {
6666 if ( skipState ) {
67- core . debug ( `Cache.save caching ${ this . ghaCacheKey } to GitHub Actions cache` ) ;
68- await cache . saveCache ( [ this . cacheDir ] , this . ghaCacheKey ) ;
67+ try {
68+ core . debug ( `Cache.save caching ${ this . ghaCacheKey } to GitHub Actions cache` ) ;
69+ await cache . saveCache ( [ this . cacheDir ] , this . ghaCacheKey ) ;
70+ } catch ( e ) {
71+ core . warning ( `Failed to save cache: ${ e } ` ) ;
72+ }
6973 } else {
7074 core . debug ( `Cache.save sending ${ this . ghaCacheKey } to post state` ) ;
7175 core . saveState (
@@ -82,26 +86,28 @@ export class Cache {
8286 }
8387
8488 public async find ( ) : Promise < string > {
85- let htcPath = tc . find ( this . opts . htcName , this . opts . htcVersion , this . platform ( ) ) ;
86- if ( htcPath ) {
87- core . info ( `Restored from hosted tool cache ${ htcPath } ` ) ;
88- return this . copyToCache ( `${ htcPath } /${ this . opts . cacheFile } ` ) ;
89- }
90-
91- if ( ! this . ghaNoCache && cache . isFeatureAvailable ( ) ) {
92- core . debug ( `GitHub Actions cache feature available` ) ;
93- if ( await cache . restoreCache ( [ this . cacheDir ] , this . ghaCacheKey ) ) {
94- core . info ( `Restored ${ this . ghaCacheKey } from GitHub Actions cache` ) ;
95- htcPath = await tc . cacheDir ( this . cacheDir , this . opts . htcName , this . opts . htcVersion , this . platform ( ) ) ;
96- core . info ( `Cached to hosted tool cache ${ htcPath } ` ) ;
89+ try {
90+ let htcPath = tc . find ( this . opts . htcName , this . opts . htcVersion , this . platform ( ) ) ;
91+ if ( htcPath ) {
92+ core . info ( `Restored from hosted tool cache ${ htcPath } ` ) ;
9793 return this . copyToCache ( `${ htcPath } /${ this . opts . cacheFile } ` ) ;
9894 }
99- } else if ( this . ghaNoCache ) {
100- core . info ( `GitHub Actions cache disabled` ) ;
101- } else {
102- core . info ( `GitHub Actions cache feature not available` ) ;
95+ if ( ! this . ghaNoCache && cache . isFeatureAvailable ( ) ) {
96+ core . debug ( `GitHub Actions cache feature available` ) ;
97+ if ( await cache . restoreCache ( [ this . cacheDir ] , this . ghaCacheKey ) ) {
98+ core . info ( `Restored ${ this . ghaCacheKey } from GitHub Actions cache` ) ;
99+ htcPath = await tc . cacheDir ( this . cacheDir , this . opts . htcName , this . opts . htcVersion , this . platform ( ) ) ;
100+ core . info ( `Cached to hosted tool cache ${ htcPath } ` ) ;
101+ return this . copyToCache ( `${ htcPath } /${ this . opts . cacheFile } ` ) ;
102+ }
103+ } else if ( this . ghaNoCache ) {
104+ core . info ( `GitHub Actions cache disabled` ) ;
105+ } else {
106+ core . info ( `GitHub Actions cache feature not available` ) ;
107+ }
108+ } catch ( e ) {
109+ core . warning ( `Failed to restore cache: ${ e } ` ) ;
103110 }
104-
105111 return '' ;
106112 }
107113
@@ -120,13 +126,17 @@ export class Cache {
120126 if ( ! cacheState . dir || ! cacheState . key ) {
121127 throw new Error ( `Invalid cache post state: ${ state } ` ) ;
122128 }
123- core . info ( `Caching ${ cacheState . key } to GitHub Actions cache` ) ;
124- await cache . saveCache ( [ cacheState . dir ] , cacheState . key ) ;
129+ try {
130+ core . info ( `Caching ${ cacheState . key } to GitHub Actions cache` ) ;
131+ await cache . saveCache ( [ cacheState . dir ] , cacheState . key ) ;
132+ } catch ( e ) {
133+ core . warning ( `Failed to save cache: ${ e } ` ) ;
134+ }
125135 return cacheState ;
126136 }
127137
128138 private copyToCache ( file : string ) : string {
129- core . debug ( `Copying ${ file } to ${ this . cachePath } ` ) ;
139+ core . info ( `Copying ${ file } to ${ this . cachePath } ` ) ;
130140 fs . copyFileSync ( file , this . cachePath ) ;
131141 return this . cachePath ;
132142 }
0 commit comments