From d78ac4e8518f3eb8464be803d4112ffbaf05bf40 Mon Sep 17 00:00:00 2001 From: Prajjwal Date: Mon, 3 Jun 2024 17:01:03 +0530 Subject: [PATCH] removes duplicate extraction --- packages/warp-cache/package.json | 2 +- packages/warp-cache/src/cache.ts | 32 +++++++++++++++----------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/packages/warp-cache/package.json b/packages/warp-cache/package.json index fffed1ed..391ec711 100644 --- a/packages/warp-cache/package.json +++ b/packages/warp-cache/package.json @@ -1,6 +1,6 @@ { "name": "github-actions.warp-cache", - "version": "1.1.14", + "version": "1.1.15", "preview": true, "description": "Github action to use WarpBuild's in-house cache offering", "keywords": [ diff --git a/packages/warp-cache/src/cache.ts b/packages/warp-cache/src/cache.ts index b21bef5a..4bf08219 100644 --- a/packages/warp-cache/src/cache.ts +++ b/packages/warp-cache/src/cache.ts @@ -123,7 +123,7 @@ export async function restoreCache( ) core.debug(`Archive Path: ${archivePath}`) - let cacheKey: string = '' + let cacheKey = cacheEntry?.cache_entry?.cache_user_given_key ?? primaryKey switch (cacheEntry.provider) { case 's3': { @@ -131,8 +131,6 @@ export async function restoreCache( return undefined } - cacheKey = cacheEntry.s3.pre_signed_url - if (options?.lookupOnly) { core.info('Lookup only - skipping download') return cacheKey @@ -167,20 +165,21 @@ export async function restoreCache( core.info('Cache Miss. Failed to download cache.') return undefined } + + if (core.isDebug()) { + await listTar(archivePath, compressionMethod) + } + + const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath) + core.info( + `Cache Size: ~${Math.round( + archiveFileSize / (1024 * 1024) + )} MB (${archiveFileSize} B)` + ) + + await extractTar(archivePath, compressionMethod) } - if (core.isDebug()) { - await listTar(archivePath, compressionMethod) - } - - const archiveFileSize = utils.getArchiveFileSizeInBytes(archivePath) - core.info( - `Cache Size: ~${Math.round( - archiveFileSize / (1024 * 1024) - )} MB (${archiveFileSize} B)` - ) - - await extractTar(archivePath, compressionMethod) core.info('Cache restored successfully') break } @@ -189,7 +188,6 @@ export async function restoreCache( if (!cacheEntry.gcs?.cache_key) { return undefined } - cacheKey = cacheEntry.gcs?.cache_key if (options?.lookupOnly) { core.info('Lookup only - skipping download') @@ -280,7 +278,7 @@ export async function restoreCache( } } - return cacheEntry?.cache_entry?.cache_user_given_key ?? cacheKey + return cacheKey } catch (error) { const typedError = error as Error if (typedError.name === ValidationError.name) {