mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-01-01 22:47:19 +03:00
Fixed applied
patch info field caching
This commit is contained in:
parent
3af42f2aff
commit
d81aa0df31
1 changed files with 22 additions and 4 deletions
|
@ -176,10 +176,11 @@ export default class Patch
|
||||||
public static getPatchInfo(version: string, source: 'origin' | 'additional' = 'origin'): Promise<PatchInfo|null>
|
public static getPatchInfo(version: string, source: 'origin' | 'additional' = 'origin'): Promise<PatchInfo|null>
|
||||||
{
|
{
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
const resolveOutput = (output: PatchInfo|null) => {
|
const resolveOutput = (output: PatchInfo|null, unityPlayerHash: string|null = null) => {
|
||||||
Cache.set(`Patch.getPatchInfo.${version}.${source}`, {
|
Cache.set(`Patch.getPatchInfo.${version}.${source}`, {
|
||||||
available: true,
|
available: true,
|
||||||
output: output
|
output: output,
|
||||||
|
playerHash: unityPlayerHash
|
||||||
}, 6 * 3600);
|
}, 6 * 3600);
|
||||||
|
|
||||||
resolve(output);
|
resolve(output);
|
||||||
|
@ -202,7 +203,24 @@ export default class Patch
|
||||||
if (cache && !cache.expired)
|
if (cache && !cache.expired)
|
||||||
{
|
{
|
||||||
if (cache.value['available'])
|
if (cache.value['available'])
|
||||||
resolve(cache.value['output']);
|
{
|
||||||
|
// Verify UnityPlayer.dll file hash
|
||||||
|
// before responding whether the patch applied or not
|
||||||
|
if (cache.value['playerHash'] !== null)
|
||||||
|
{
|
||||||
|
constants.paths.gameDir.then((gameDir) => {
|
||||||
|
Neutralino.filesystem.readBinaryFile(`${gameDir}/UnityPlayer.dll`)
|
||||||
|
.then((currPlayer: ArrayBuffer) => {
|
||||||
|
cache.value['output']['applied'] = md5(currPlayer) != cache.value['playerHash'];
|
||||||
|
|
||||||
|
resolve(cache.value['output']);
|
||||||
|
})
|
||||||
|
.catch(() => resolve(cache.value['output']));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
else resolve(cache.value['output']);
|
||||||
|
}
|
||||||
|
|
||||||
else reject(cache.value['error']);
|
else reject(cache.value['error']);
|
||||||
}
|
}
|
||||||
|
@ -285,7 +303,7 @@ export default class Patch
|
||||||
.then((currPlayer: ArrayBuffer) => {
|
.then((currPlayer: ArrayBuffer) => {
|
||||||
patchInfo.applied = md5(currPlayer) != originalPlayer[1];
|
patchInfo.applied = md5(currPlayer) != originalPlayer[1];
|
||||||
|
|
||||||
resolveOutput(patchInfo);
|
resolveOutput(patchInfo, originalPlayer[1]);
|
||||||
})
|
})
|
||||||
.catch(() => resolveOutput(patchInfo));
|
.catch(() => resolveOutput(patchInfo));
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue