Skip to content

Commit

Permalink
Hash mods asynchronously (#1055)
Browse files Browse the repository at this point in the history
  • Loading branch information
chompDev authored Jan 9, 2025
2 parents 18b4488 + e86ceb8 commit 6283635
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions project/src/services/ModCompilerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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, {
Expand Down
8 changes: 4 additions & 4 deletions project/src/services/cache/ModHashCacheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean> {
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<void> {
const generatedHash = await this.hashUtil.generateSha1ForDataAsync(modContent);

this.storeValue(modName, generatedHash);
}
Expand Down

0 comments on commit 6283635

Please sign in to comment.