chore: Tune logging for applications cache items disposal
MODIFY
lib/basedriver/helpers.js
lib/basedriver/helpers.js
@@ -18,16 +18,17 @@ const ZIP_MIME_TYPES = [
'application/x-zip-compressed',
'multipart/x-zip',
];
-const CACHED_APPS_MAX_AGE = 1000 * 60 * 60 * 24;
+const CACHED_APPS_MAX_AGE = 1000 * 60 * 60 * 24; // ms
const APPLICATIONS_CACHE = new LRU({
maxAge: CACHED_APPS_MAX_AGE, // expire after 24 hours
updateAgeOnGet: true,
dispose: async (app, {fullPath}) => {
- logger.info(`The application '${app}' cached at '${fullPath}' ` +
- `has expired after ${CACHED_APPS_MAX_AGE}ms`);
- if (await fs.exists(fullPath)) {
- await fs.rimraf(fullPath);
+ if (!await fs.exists(fullPath)) {
+ return;
}
+
+ logger.info(`The application '${app}' cached at '${fullPath}' has expired`);
+ await fs.rimraf(fullPath);
},
noDisposeOnSet: true,
});
@@ -39,10 +40,9 @@ process.on('exit', () => {
if (!APPLICATIONS_CACHE.length) {
return;
}
+
const appPaths = APPLICATIONS_CACHE.values()
.map(({fullPath}) => fullPath);
- APPLICATIONS_CACHE.reset();
-
logger.debug(`Performing cleanup of ${appPaths.length} cached ` +
`application${appPaths.length === 1 ? '' : 's'}`);
for (const appPath of appPaths) {

chore: Tune logging for applications cache items disposal (#380)