@@ -49,8 +49,8 @@ class LayerCache {
4949 }
5050
5151 private async saveImageAsUnpacked ( ) {
52- await this . exec ( ' mkdir -p' , [ this . getSavedImageTarDir ( ) ] , { silent : true } )
53- await this . exec ( `sh -c` , [ `docker save '${ ( await this . makeRepotagsDockerSaveArgReady ( this . ids ) ) . join ( `' '` ) } ' | tar xf - -C ${ this . getSavedImageTarDir ( ) } ` ] )
52+ await fs . mkdir ( this . getSavedImageTarDir ( ) , { recursive : true } )
53+ await this . exec ( `sh -c` , [ `docker save '${ ( await this . makeRepotagsDockerSaveArgReady ( this . ids ) ) . join ( `' '` ) } ' | tar xf - -C .` ] , { cwd : this . getSavedImageTarDir ( ) } )
5454 }
5555
5656 private async makeRepotagsDockerSaveArgReady ( repotags : string [ ] ) : Promise < string [ ] > {
@@ -133,14 +133,15 @@ class LayerCache {
133133 }
134134 }
135135
136- private async storeSingleLayerBy ( id : string ) : Promise < number > {
137- const path = this . genSingleLayerStorePath ( id )
138- const key = await this . generateSingleLayerSaveKey ( id )
136+ private async storeSingleLayerBy ( layerId : string ) : Promise < number > {
137+ const path = this . genSingleLayerStorePath ( layerId )
138+ const key = await this . generateSingleLayerSaveKey ( layerId )
139139
140- core . info ( `Start storing layer cache: ${ key } ` )
140+ core . info ( `Start storing layer cache: ${ JSON . stringify ( { layerId , key } ) } ` )
141141 const cacheId = await LayerCache . dismissError ( cache . saveCache ( [ path ] , key ) , LayerCache . ERROR_CACHE_ALREAD_EXISTS_STR , - 1 )
142- core . info ( `Stored layer cache, key : ${ key } , id: ${ cacheId } ` )
142+ core . info ( `Stored layer cache: ${ JSON . stringify ( { key, cacheId } ) } ` )
143143
144+ core . debug ( JSON . stringify ( { log : `storeSingleLayerBy` , layerId, path, key, cacheId} ) )
144145 return cacheId
145146 }
146147
@@ -177,8 +178,9 @@ class LayerCache {
177178 }
178179
179180 private async restoreLayers ( ) : Promise < boolean > {
180- const pool = new PromisePool ( this . concurrency )
181181
182+
183+ const pool = new PromisePool ( this . concurrency )
182184 const tasks = ( await this . getLayerIds ( ) ) . map (
183185 layerId => pool . open ( ( ) => this . restoreSingleLayerBy ( layerId ) )
184186 )
@@ -201,9 +203,14 @@ class LayerCache {
201203 }
202204
203205 private async restoreSingleLayerBy ( id : string ) : Promise < string > {
204- core . debug ( JSON . stringify ( { log : `restoreSingleLayerBy` , id } ) )
206+ const path = this . genSingleLayerStorePath ( id )
207+ const key = await this . recoverSingleLayerKey ( id )
208+ const dir = path . replace ( / [ ^ / \\ ] + $ / , `` )
209+
210+ core . debug ( JSON . stringify ( { log : `restoreSingleLayerBy` , id, path, dir, key } ) )
205211
206- const result = await cache . restoreCache ( [ this . genSingleLayerStorePath ( id ) ] , await this . recoverSingleLayerKey ( id ) )
212+ await fs . mkdir ( dir , { recursive : true } )
213+ const result = await cache . restoreCache ( [ path ] , key )
207214
208215 if ( result == null ) {
209216 throw new Error ( `${ LayerCache . ERROR_LAYER_CACHE_NOT_FOUND_STR } : ${ JSON . stringify ( { id } ) } ` )
@@ -243,7 +250,7 @@ class LayerCache {
243250 }
244251
245252 genSingleLayerStorePath ( id : string ) {
246- return `${ this . getLayerCachesDir ( ) } /${ id } /layer.tar`
253+ return path . resolve ( `${ this . getLayerCachesDir ( ) } /${ id } /layer.tar` )
247254 }
248255
249256 async generateRootHashFromManifest ( ) : Promise < string > {
0 commit comments