Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 21e6a62

Browse files
committed
Use common getTotalCacheSize for TRAP caching
1 parent 0cb7129 commit 21e6a62

9 files changed

+9
-28
lines changed

lib/analyze-action.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init-action.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/trap-caching.js

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/trap-caching.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze-action.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
} from "./analyze";
1717
import { getApiDetails, getGitHubVersion } from "./api-client";
1818
import { runAutobuild } from "./autobuild";
19-
import { shouldStoreCache } from "./caching-utils";
19+
import { getTotalCacheSize, shouldStoreCache } from "./caching-utils";
2020
import { getCodeQL } from "./codeql";
2121
import { Config, getConfig } from "./config-utils";
2222
import { uploadDatabases } from "./database-upload";
@@ -36,7 +36,6 @@ import {
3636
} from "./status-report";
3737
import {
3838
cleanupTrapCaches,
39-
getTotalCacheSize,
4039
TrapCacheCleanupStatusReport,
4140
uploadTrapCaches,
4241
} from "./trap-caching";
@@ -94,7 +93,7 @@ async function sendStatusReport(
9493
...report,
9594
trap_cache_upload_duration_ms: Math.round(trapCacheUploadTime || 0),
9695
trap_cache_upload_size_bytes: Math.round(
97-
await getTotalCacheSize(config.trapCaches, logger),
96+
await getTotalCacheSize(Object.values(config.trapCaches), logger),
9897
),
9998
};
10099
await statusReport.sendStatusReport(trapCacheUploadStatusReport);

src/init-action.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { getGitHubVersion } from "./api-client";
1818
import {
1919
getDependencyCachingEnabled,
20+
getTotalCacheSize,
2021
shouldRestoreCache,
2122
} from "./caching-utils";
2223
import { CodeQL } from "./codeql";
@@ -51,7 +52,6 @@ import {
5152
import { ZstdAvailability } from "./tar";
5253
import { ToolsDownloadStatusReport } from "./tools-download";
5354
import { ToolsFeature } from "./tools-features";
54-
import { getTotalCacheSize } from "./trap-caching";
5555
import {
5656
checkDiskUsage,
5757
checkForTimeout,
@@ -230,7 +230,7 @@ async function sendCompletedStatusReport(
230230
packs: JSON.stringify(packs),
231231
trap_cache_languages: Object.keys(config.trapCaches).join(","),
232232
trap_cache_download_size_bytes: Math.round(
233-
await getTotalCacheSize(config.trapCaches, logger),
233+
await getTotalCacheSize(Object.values(config.trapCaches), logger),
234234
),
235235
trap_cache_download_duration_ms: Math.round(config.trapCacheDownloadTime),
236236
query_filters: JSON.stringify(

src/trap-caching.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,6 @@ export async function getLanguagesSupportingCaching(
312312
return result;
313313
}
314314

315-
export async function getTotalCacheSize(
316-
trapCaches: Partial<Record<Language, string>>,
317-
logger: Logger,
318-
): Promise<number> {
319-
const sizes = await Promise.all(
320-
Object.values(trapCaches).map((cacheDir) =>
321-
tryGetFolderBytes(cacheDir, logger),
322-
),
323-
);
324-
return sizes.map((a) => a || 0).reduce((a, b) => a + b, 0);
325-
}
326-
327315
async function cacheKey(
328316
codeql: CodeQL,
329317
language: Language,

0 commit comments

Comments
 (0)