Don not try to delete cache if it does not exists
This commit is contained in:
parent
cab99b362b
commit
8986f6218b
|
@ -1636,7 +1636,7 @@ const resetCacheWithOctokit = (cacheKey) => __awaiter(void 0, void 0, void 0, fu
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (error.status) {
|
if (error.status) {
|
||||||
core.debug(`Cache ${cacheKey} does not exist`);
|
core.warning(`Error delete ${cacheKey}: [${error.status}] ${error.message || 'Unknown reason'}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw error;
|
throw error;
|
||||||
|
@ -1650,7 +1650,10 @@ class StateCacheStorage {
|
||||||
const filePath = path_1.default.join(tmpDir, STATE_FILE);
|
const filePath = path_1.default.join(tmpDir, STATE_FILE);
|
||||||
fs_1.default.writeFileSync(filePath, serializedState);
|
fs_1.default.writeFileSync(filePath, serializedState);
|
||||||
try {
|
try {
|
||||||
yield resetCacheWithOctokit(CACHE_KEY);
|
const cacheExists = yield checkIfCacheExists(CACHE_KEY);
|
||||||
|
if (cacheExists) {
|
||||||
|
yield resetCacheWithOctokit(CACHE_KEY);
|
||||||
|
}
|
||||||
const fileSize = fs_1.default.statSync(filePath).size;
|
const fileSize = fs_1.default.statSync(filePath).size;
|
||||||
if (fileSize === 0) {
|
if (fileSize === 0) {
|
||||||
core.info(`the state will be removed`);
|
core.info(`the state will be removed`);
|
||||||
|
|
|
@ -54,7 +54,11 @@ const resetCacheWithOctokit = async (cacheKey: string): Promise<void> => {
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.status) {
|
if (error.status) {
|
||||||
core.debug(`Cache ${cacheKey} does not exist`);
|
core.warning(
|
||||||
|
`Error delete ${cacheKey}: [${error.status}] ${
|
||||||
|
error.message || 'Unknown reason'
|
||||||
|
}`
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +71,10 @@ export class StateCacheStorage implements IStateStorage {
|
||||||
fs.writeFileSync(filePath, serializedState);
|
fs.writeFileSync(filePath, serializedState);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await resetCacheWithOctokit(CACHE_KEY);
|
const cacheExists = await checkIfCacheExists(CACHE_KEY);
|
||||||
|
if (cacheExists) {
|
||||||
|
await resetCacheWithOctokit(CACHE_KEY);
|
||||||
|
}
|
||||||
const fileSize = fs.statSync(filePath).size;
|
const fileSize = fs.statSync(filePath).size;
|
||||||
|
|
||||||
if (fileSize === 0) {
|
if (fileSize === 0) {
|
||||||
|
|
Loading…
Reference in New Issue