From e86ceb89cecdd12ca8a96a4b10e64391cd46485f Mon Sep 17 00:00:00 2001 From: Archangel Date: Thu, 9 Jan 2025 18:07:48 +0100 Subject: [PATCH] Hash mods asynchronously --- project/src/services/ModCompilerService.ts | 4 ++-- project/src/services/cache/ModHashCacheService.ts | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/project/src/services/ModCompilerService.ts b/project/src/services/ModCompilerService.ts index 8dcb9378..1d7b0f77 100644 --- a/project/src/services/ModCompilerService.ts +++ b/project/src/services/ModCompilerService.ts @@ -42,7 +42,7 @@ export class ModCompilerService { } } - const hashMatches = this.modHashCacheService.calculateAndCompareHash(modName, tsFileContents); + const hashMatches = await this.modHashCacheService.calculateAndCompareHash(modName, tsFileContents); if (fileExists && hashMatches) { // Everything exists and matches, escape early @@ -51,7 +51,7 @@ export class ModCompilerService { if (!hashMatches) { // Store / update hash in json file - this.modHashCacheService.calculateAndStoreHash(modName, tsFileContents); + await this.modHashCacheService.calculateAndStoreHash(modName, tsFileContents); } return this.compile(modTypeScriptFiles, { diff --git a/project/src/services/cache/ModHashCacheService.ts b/project/src/services/cache/ModHashCacheService.ts index 388baee5..9cd73f98 100644 --- a/project/src/services/cache/ModHashCacheService.ts +++ b/project/src/services/cache/ModHashCacheService.ts @@ -38,14 +38,14 @@ export class ModHashCacheService { return this.getStoredValue(modName) === hash; } - public calculateAndCompareHash(modName: string, modContent: string): boolean { - const generatedHash = this.hashUtil.generateSha1ForData(modContent); + public async calculateAndCompareHash(modName: string, modContent: string): Promise { + const generatedHash = await this.hashUtil.generateSha1ForDataAsync(modContent); return this.matchWithStoredHash(modName, generatedHash); } - public calculateAndStoreHash(modName: string, modContent: string): void { - const generatedHash = this.hashUtil.generateSha1ForData(modContent); + public async calculateAndStoreHash(modName: string, modContent: string): Promise { + const generatedHash = await this.hashUtil.generateSha1ForDataAsync(modContent); this.storeValue(modName, generatedHash); }