Skip to content

Commit

Permalink
fix: Downgrade log level for http cache cleanup (#28447)
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Apr 16, 2024
1 parent 41e6be8 commit 49005e0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/util/cache/repository/http-cache.spec.ts
Expand Up @@ -10,7 +10,7 @@ describe('util/cache/repository/http-cache', () => {
});

it('should not throw if cache is not a valid HttpCache', () => {
expect(() => cleanupHttpCache('not a valid cache')).not.toThrow();
expect(() => cleanupHttpCache({})).not.toThrow();
});

it('should remove expired items from the cache', () => {
Expand Down
10 changes: 5 additions & 5 deletions lib/util/cache/repository/http-cache.ts
@@ -1,15 +1,15 @@
import is from '@sindresorhus/is';
import { DateTime } from 'luxon';
import { GlobalConfig } from '../../../config/global';
import { logger } from '../../../logger';
import { HttpCacheSchema } from '../../http/cache/schema';
import type { RepoCacheData } from './types';

export function cleanupHttpCache(cacheData: unknown): void {
if (!is.plainObject(cacheData) || !is.plainObject(cacheData['httpCache'])) {
logger.warn('cleanupHttpCache: invalid cache data');
export function cleanupHttpCache(cacheData: RepoCacheData): void {
const { httpCache } = cacheData;
if (!httpCache) {
logger.trace('cleanupHttpCache: no http cache to clean up');
return;
}
const httpCache = cacheData['httpCache'];

const ttlDays = GlobalConfig.get('httpCacheTtlDays', 90);
if (ttlDays === 0) {
Expand Down
4 changes: 1 addition & 3 deletions lib/util/cache/repository/impl/base.ts
Expand Up @@ -71,9 +71,7 @@ export abstract class RepoCacheBase implements RepoCache {
}

async save(): Promise<void> {
if (this.data) {
cleanupHttpCache(this.data);
}
cleanupHttpCache(this.data);
const jsonStr = safeStringify(this.data);
const hashedJsonStr = hash(jsonStr);
if (hashedJsonStr === this.oldHash) {
Expand Down

0 comments on commit 49005e0

Please sign in to comment.