Skip to content
Snippets Groups Projects
Unverified Commit 4459b112 authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

fix(cache): improve repository cache robustness (#6689)

parent e015875a
No related branches found
No related tags found
No related merge requests found
...@@ -45,6 +45,6 @@ describe('lib/util/cache/repository', () => { ...@@ -45,6 +45,6 @@ describe('lib/util/cache/repository', () => {
expect(fs.outputFile.mock.calls).toHaveLength(1); expect(fs.outputFile.mock.calls).toHaveLength(1);
}); });
it('gets', () => { it('gets', () => {
expect(repositoryCache.getCache()).toEqual({ repository: 'abc/def' }); expect(repositoryCache.getCache()).toEqual({});
}); });
}); });
...@@ -56,15 +56,19 @@ export async function initialize(config: RenovateConfig): Promise<void> { ...@@ -56,15 +56,19 @@ export async function initialize(config: RenovateConfig): Promise<void> {
} catch (err) { } catch (err) {
logger.debug({ cacheFileName }, 'Repository cache not found'); logger.debug({ cacheFileName }, 'Repository cache not found');
} }
cache = cache || { repository: config.repository }; cache = cache || Object.create({});
cache.repository = config.repository;
} }
export function getCache(): Cache { export function getCache(): Cache {
cache = cache || Object.create({});
return cache; return cache;
} }
export async function finalize(): Promise<void> { export async function finalize(): Promise<void> {
if (repositoryCache !== 'disabled') { if (cacheFileName && cache && repositoryCache !== 'disabled') {
await fs.outputFile(cacheFileName, JSON.stringify(cache)); await fs.outputFile(cacheFileName, JSON.stringify(cache));
} }
cacheFileName = null;
cache = Object.create({});
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment