Add caching utils

This commit is contained in:
Michael B. Gale 2024-07-22 15:25:54 +01:00
parent 19e7c25974
commit 51d90f48a6
No known key found for this signature in database
GPG key ID: FF5E2765BD00628F
3 changed files with 34 additions and 0 deletions

15
lib/caching-utils.js generated Normal file
View file

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTotalCacheSize = getTotalCacheSize;
const util_1 = require("./util");
/**
* Returns the total size of all the specified paths.
* @param paths The paths for which to calculate the total size.
* @param logger A logger to record some informational messages to.
* @returns The total size of all specified paths.
*/
async function getTotalCacheSize(paths, logger) {
const sizes = await Promise.all(paths.map((cacheDir) => (0, util_1.tryGetFolderBytes)(cacheDir, logger)));
return sizes.map((a) => a || 0).reduce((a, b) => a + b, 0);
}
//# sourceMappingURL=caching-utils.js.map