mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-24 20:26:24 +00:00
Make updates atomic again
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { createReadStream } from 'fs';
|
||||
import { pipeline } from 'stream/promises';
|
||||
import { createHash } from 'crypto';
|
||||
|
||||
import * as Errors from '../types/errors';
|
||||
@@ -23,9 +24,7 @@ export async function checkIntegrity(
|
||||
): Promise<CheckIntegrityResultType> {
|
||||
try {
|
||||
const hash = createHash('sha512');
|
||||
for await (const chunk of createReadStream(fileName)) {
|
||||
hash.update(chunk);
|
||||
}
|
||||
await pipeline(createReadStream(fileName), hash);
|
||||
|
||||
const actualSHA512 = hash.digest('base64');
|
||||
if (sha512 === actualSHA512) {
|
||||
|
||||
Reference in New Issue
Block a user