From bf390765546ee77313c6a038bdaa1bd7f2737318 Mon Sep 17 00:00:00 2001 From: Mikhail Ryzhov Date: Mon, 25 Mar 2024 11:45:24 +0100 Subject: [PATCH] lock using uncomplete caches --- .github/actions/cache/dist/save-only/index.js | 8 ++++++-- .github/actions/cache/dist/save/index.js | 8 ++++++-- .github/actions/cache/src/saveImpl.js | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/.github/actions/cache/dist/save-only/index.js b/.github/actions/cache/dist/save-only/index.js index 1e316b45bb8ecc..0303ed8a8135af 100644 --- a/.github/actions/cache/dist/save-only/index.js +++ b/.github/actions/cache/dist/save-only/index.js @@ -33221,6 +33221,8 @@ async function save() { var tarName = `${key}.cache` var tarPath = path.join(cacheRemotePath, tarName) + var tarNameTmp = `${key}.tmp` + var tarPathTmp = path.join(cacheRemotePath, tarNameTmp) if (fs.existsSync(tarPath)) { core.warning(`Cache file ${tarName} already exists`) @@ -33248,8 +33250,10 @@ async function save() { } core.info('Copying cache...') - fs.copyFileSync(tarName, tarPath) - core.info(`${tarName} was copied to ${tarPath}`) + fs.copyFileSync(tarName, tarPathTmp) + // After copying is done, rename file + fs.renameSync(tarPathTmp, tarPath) + core.info(`${tarName} copied to ${tarPath}`) core.setOutput('cache-file', tarName) core.setOutput('cache-hit', true) diff --git a/.github/actions/cache/dist/save/index.js b/.github/actions/cache/dist/save/index.js index 1e316b45bb8ecc..0303ed8a8135af 100644 --- a/.github/actions/cache/dist/save/index.js +++ b/.github/actions/cache/dist/save/index.js @@ -33221,6 +33221,8 @@ async function save() { var tarName = `${key}.cache` var tarPath = path.join(cacheRemotePath, tarName) + var tarNameTmp = `${key}.tmp` + var tarPathTmp = path.join(cacheRemotePath, tarNameTmp) if (fs.existsSync(tarPath)) { core.warning(`Cache file ${tarName} already exists`) @@ -33248,8 +33250,10 @@ async function save() { } core.info('Copying cache...') - fs.copyFileSync(tarName, tarPath) - core.info(`${tarName} was copied to ${tarPath}`) + fs.copyFileSync(tarName, tarPathTmp) + // After copying is done, rename file + fs.renameSync(tarPathTmp, tarPath) + core.info(`${tarName} copied to ${tarPath}`) core.setOutput('cache-file', tarName) core.setOutput('cache-hit', true) diff --git a/.github/actions/cache/src/saveImpl.js b/.github/actions/cache/src/saveImpl.js index 717f0f72adb70f..6e40833ca89596 100644 --- a/.github/actions/cache/src/saveImpl.js +++ b/.github/actions/cache/src/saveImpl.js @@ -25,6 +25,8 @@ async function save() { var tarName = `${key}.cache` var tarPath = path.join(cacheRemotePath, tarName) + var tarNameTmp = `${key}.tmp` + var tarPathTmp = path.join(cacheRemotePath, tarNameTmp) if (fs.existsSync(tarPath)) { core.warning(`Cache file ${tarName} already exists`) @@ -52,8 +54,10 @@ async function save() { } core.info('Copying cache...') - fs.copyFileSync(tarName, tarPath) - core.info(`${tarName} was copied to ${tarPath}`) + fs.copyFileSync(tarName, tarPathTmp) + // After copying is done, rename file + fs.renameSync(tarPathTmp, tarPath) + core.info(`${tarName} copied to ${tarPath}`) core.setOutput('cache-file', tarName) core.setOutput('cache-hit', true)