Merge from vscode cfc1ab4c5f816765b91fb7ead3c3427a7c8581a3

This commit is contained in:
ADS Merger
2020-03-11 04:19:23 +00:00
parent 16fab722d5
commit 4c3e48773d
880 changed files with 20441 additions and 11232 deletions

View File

@@ -5,19 +5,17 @@
import * as fs from 'fs';
import * as crypto from 'crypto';
import * as stream from 'stream';
import { once } from 'vs/base/common/functional';
export function checksum(path: string, sha1hash: string | undefined): Promise<void> {
const promise = new Promise<string | undefined>((c, e) => {
const input = fs.createReadStream(path);
const hash = crypto.createHash('sha1');
const hashStream = hash as any as stream.PassThrough;
input.pipe(hashStream);
input.pipe(hash);
const done = once((err?: Error, result?: string) => {
input.removeAllListeners();
hashStream.removeAllListeners();
hash.removeAllListeners();
if (err) {
e(err);
@@ -28,8 +26,8 @@ export function checksum(path: string, sha1hash: string | undefined): Promise<vo
input.once('error', done);
input.once('end', done);
hashStream.once('error', done);
hashStream.once('data', (data: Buffer) => done(undefined, data.toString('hex')));
hash.once('error', done);
hash.once('data', (data: Buffer) => done(undefined, data.toString('hex')));
});
return promise.then(hash => {