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:
parent
ab1b5cd30e
commit
e86ceb89ce
@ -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) {
|
if (fileExists && hashMatches) {
|
||||||
// Everything exists and matches, escape early
|
// Everything exists and matches, escape early
|
||||||
@ -51,7 +51,7 @@ export class ModCompilerService {
|
|||||||
|
|
||||||
if (!hashMatches) {
|
if (!hashMatches) {
|
||||||
// Store / update hash in json file
|
// Store / update hash in json file
|
||||||
this.modHashCacheService.calculateAndStoreHash(modName, tsFileContents);
|
await this.modHashCacheService.calculateAndStoreHash(modName, tsFileContents);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.compile(modTypeScriptFiles, {
|
return this.compile(modTypeScriptFiles, {
|
||||||
|
@ -38,14 +38,14 @@ export class ModHashCacheService {
|
|||||||
return this.getStoredValue(modName) === hash;
|
return this.getStoredValue(modName) === hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public calculateAndCompareHash(modName: string, modContent: string): boolean {
|
public async calculateAndCompareHash(modName: string, modContent: string): Promise<boolean> {
|
||||||
const generatedHash = this.hashUtil.generateSha1ForData(modContent);
|
const generatedHash = await this.hashUtil.generateSha1ForDataAsync(modContent);
|
||||||
|
|
||||||
return this.matchWithStoredHash(modName, generatedHash);
|
return this.matchWithStoredHash(modName, generatedHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
public calculateAndStoreHash(modName: string, modContent: string): void {
|
public async calculateAndStoreHash(modName: string, modContent: string): Promise<void> {
|
||||||
const generatedHash = this.hashUtil.generateSha1ForData(modContent);
|
const generatedHash = await this.hashUtil.generateSha1ForDataAsync(modContent);
|
||||||
|
|
||||||
this.storeValue(modName, generatedHash);
|
this.storeValue(modName, generatedHash);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user