Improve log message when there's nothing to clean up

This commit is contained in:
Henry Mercer 2024-05-23 16:19:44 +01:00
parent f7f71927cf
commit fdba1f907e
3 changed files with 13 additions and 3 deletions

6
lib/trap-caching.js generated
View file

@ -155,8 +155,12 @@ async function cleanupTrapCaches(config, features, logger) {
// Keep the most recent cache
const mostRecentCache = cachesToRemove.pop();
logger.debug(`Keeping most recent TRAP cache (${JSON.stringify(mostRecentCache)})`);
if (cachesToRemove.length === 0) {
logger.info(`No TRAP caches to clean up for ${language}.`);
continue;
}
for (const cache of cachesToRemove) {
logger.debug(`Deleting old TRAP cache (${JSON.stringify(cache)})`);
logger.debug(`Cleaning up TRAP cache (${JSON.stringify(cache)})`);
await apiClient.deleteActionsCache(cache.id);
}
const bytesCleanedUp = cachesToRemove.reduce((acc, item) => acc + item.size_in_bytes, 0);

File diff suppressed because one or more lines are too long

View file

@ -206,8 +206,14 @@ export async function cleanupTrapCaches(
logger.debug(
`Keeping most recent TRAP cache (${JSON.stringify(mostRecentCache)})`,
);
if (cachesToRemove.length === 0) {
logger.info(`No TRAP caches to clean up for ${language}.`);
continue;
}
for (const cache of cachesToRemove) {
logger.debug(`Deleting old TRAP cache (${JSON.stringify(cache)})`);
logger.debug(`Cleaning up TRAP cache (${JSON.stringify(cache)})`);
await apiClient.deleteActionsCache(cache.id);
}
const bytesCleanedUp = cachesToRemove.reduce(