0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 09:50:43 -05:00

Hash mods asynchronously

This commit is contained in:
Archangel 2025-01-09 18:07:48 +01:00
parent ab1b5cd30e
commit e86ceb89ce
2 changed files with 6 additions and 6 deletions

View File

@ -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, {

View File

@ -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);
}