mirror of
https://github.com/remnawave/node.git
synced 2026-08-27 12:11:04 +00:00
fix: missing sha256 check
This commit is contained in:
parent
d79e6d91c6
commit
3f102e3703
1 changed files with 9 additions and 4 deletions
|
|
@ -20,7 +20,7 @@ const CoreSchema = z.object({
|
|||
core: z
|
||||
.object({
|
||||
url: z.url({ protocol: /^https$/ }),
|
||||
sha256: z.hash('sha256'),
|
||||
sha256: z.hash('sha256').transform((value) => value.toLowerCase()),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
|
@ -59,20 +59,25 @@ export class CoreLoaderService {
|
|||
return;
|
||||
}
|
||||
|
||||
if (await this.isInstalled(core.url)) return;
|
||||
if (await this.isInstalled(core)) return;
|
||||
|
||||
await this.install(core);
|
||||
}
|
||||
|
||||
private async isInstalled(url: string): Promise<boolean> {
|
||||
private async isInstalled(core: ICore): Promise<boolean> {
|
||||
try {
|
||||
const marker = JSON.parse(await readFile(CORE_MARKER, 'utf8')) as ICoreMarker;
|
||||
|
||||
if (marker.url !== url) {
|
||||
if (marker.url !== core.url) {
|
||||
this.logger.log('Configured url changed, re-downloading.');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (marker.sha256 !== core.sha256) {
|
||||
this.logger.log('Configured sha256 changed, re-downloading.');
|
||||
return false;
|
||||
}
|
||||
|
||||
const stats = await stat(CORE_CUSTOM);
|
||||
|
||||
if (stats.size !== marker.size || stats.mtimeMs !== marker.mtimeMs) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue