mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-20 01:34:24 +08:00
modify cache capacity calculation
This commit is contained in:
+3
-10
@@ -44,16 +44,9 @@ async function getCacheTotalSize(cacheName: string): Promise<number> {
|
|||||||
try {
|
try {
|
||||||
const response = await cache.match(request);
|
const response = await cache.match(request);
|
||||||
|
|
||||||
if (response && response.headers) {
|
if (response) {
|
||||||
const contentLength = response.headers.get('content-length');
|
const blob = await response.clone().blob();
|
||||||
|
totalSize += blob.size;
|
||||||
if (contentLength) {
|
|
||||||
const size = parseInt(contentLength, 10);
|
|
||||||
|
|
||||||
if (Number.isFinite(size)) {
|
|
||||||
totalSize += size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
logger.warn(`failed to get size for request ${request.url} in cache ${cacheName}`, ex);
|
logger.warn(`failed to get size for request ${request.url} in cache ${cacheName}`, ex);
|
||||||
|
|||||||
Reference in New Issue
Block a user