Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1650,16 +1650,17 @@ class StateCacheStorage {
const filePath = path_1.default.join(tmpDir, STATE_FILE);
fs_1.default.writeFileSync(filePath, serializedState);
try {
const cacheExists = yield checkIfCacheExists(CACHE_KEY);
const full_cache_key = CACHE_KEY + '_' + github_1.context.runId;
const cacheExists = yield checkIfCacheExists(full_cache_key);
if (cacheExists) {
yield resetCacheWithOctokit(CACHE_KEY);
yield resetCacheWithOctokit(full_cache_key);
}
const fileSize = fs_1.default.statSync(filePath).size;
if (fileSize === 0) {
core.info(`the state will be removed`);
return;
}
yield cache.saveCache([path_1.default.dirname(filePath)], CACHE_KEY);
yield cache.saveCache([path_1.default.dirname(filePath)], full_cache_key);
}
catch (error) {
core.warning(`Saving the state was not successful due to "${error.message || 'unknown reason'}"`);
Expand All @@ -1675,12 +1676,11 @@ class StateCacheStorage {
const filePath = path_1.default.join(tmpDir, STATE_FILE);
unlinkSafely(filePath);
try {
const cacheExists = yield checkIfCacheExists(CACHE_KEY);
const cacheExists = yield cache.restoreCache([path_1.default.dirname(filePath)], CACHE_KEY);
if (!cacheExists) {
core.info('The saved state was not found, the process starts from the first issue.');
return '';
}
yield cache.restoreCache([path_1.default.dirname(filePath)], CACHE_KEY);
if (!fs_1.default.existsSync(filePath)) {
core.warning('Unknown error when unpacking the cache, the process starts from the first issue.');
return '';
Expand Down
14 changes: 8 additions & 6 deletions src/classes/state/state-cache-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ export class StateCacheStorage implements IStateStorage {
fs.writeFileSync(filePath, serializedState);

try {
const cacheExists = await checkIfCacheExists(CACHE_KEY);
const full_cache_key = CACHE_KEY + '_' + context.runId;
const cacheExists = await checkIfCacheExists(full_cache_key);
if (cacheExists) {
await resetCacheWithOctokit(CACHE_KEY);
await resetCacheWithOctokit(full_cache_key);
}
const fileSize = fs.statSync(filePath).size;

Expand All @@ -82,7 +83,7 @@ export class StateCacheStorage implements IStateStorage {
return;
}

await cache.saveCache([path.dirname(filePath)], CACHE_KEY);
await cache.saveCache([path.dirname(filePath)], full_cache_key);
} catch (error) {
core.warning(
`Saving the state was not successful due to "${
Expand All @@ -99,16 +100,17 @@ export class StateCacheStorage implements IStateStorage {
const filePath = path.join(tmpDir, STATE_FILE);
unlinkSafely(filePath);
try {
const cacheExists = await checkIfCacheExists(CACHE_KEY);
const cacheExists = await cache.restoreCache(
[path.dirname(filePath)],
CACHE_KEY
);
if (!cacheExists) {
core.info(
'The saved state was not found, the process starts from the first issue.'
);
return '';
}

await cache.restoreCache([path.dirname(filePath)], CACHE_KEY);

if (!fs.existsSync(filePath)) {
core.warning(
'Unknown error when unpacking the cache, the process starts from the first issue.'
Expand Down