From 3cc0a8f6bbdf4d289612c5ace981b479b540f8d2 Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Tue, 21 Jun 2022 08:18:58 -0600 Subject: [PATCH] Add some explanatory comments --- src/cache-cleaner.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cache-cleaner.ts b/src/cache-cleaner.ts index df87e01..7c8ef78 100644 --- a/src/cache-cleaner.ts +++ b/src/cache-cleaner.ts @@ -12,19 +12,26 @@ export class CacheCleaner { } async prepare(): Promise { + // Reset the file-access journal so that files appear not to have been used recently fs.rmSync(path.resolve(this.gradleUserHome, 'caches/journal-1'), {recursive: true, force: true}) fs.mkdirSync(path.resolve(this.gradleUserHome, 'caches/journal-1'), {recursive: true}) fs.writeFileSync( path.resolve(this.gradleUserHome, 'caches/journal-1/file-access.properties'), 'inceptionTimestamp=0' ) + + // Set the modification time of all files to the past: this timestamp is used when there is no matching entry in the journal await this.ageAllFiles() + + // Touch all 'gc' files so that cache cleanup won't run immediately. await this.touchAllFiles('gc.properties') } async forceCleanup(): Promise { + // Age all 'gc' files so that cache cleanup will run immediately. await this.ageAllFiles('gc.properties') + // Run a dummy Gradle build to trigger cache cleanup const cleanupProjectDir = path.resolve(this.tmpDir, 'dummy-cleanup-project') fs.mkdirSync(cleanupProjectDir, {recursive: true}) fs.writeFileSync(