提交 9a4777dd 编写于 作者: J Johannes Rieken

fix #39050

上级 7326ed0f
...@@ -3,8 +3,6 @@ ...@@ -3,8 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as getmac from 'getmac';
import * as crypto from 'crypto';
import { TPromise } from 'vs/base/common/winjs.base'; import { TPromise } from 'vs/base/common/winjs.base';
import * as errors from 'vs/base/common/errors'; import * as errors from 'vs/base/common/errors';
import * as uuid from 'vs/base/common/uuid'; import * as uuid from 'vs/base/common/uuid';
...@@ -86,17 +84,22 @@ export function getMachineId(): TPromise<string> { ...@@ -86,17 +84,22 @@ export function getMachineId(): TPromise<string> {
function getMacMachineId(): TPromise<string> { function getMacMachineId(): TPromise<string> {
return new TPromise<string>(resolve => { return new TPromise<string>(resolve => {
try { TPromise.join([import('crypto'), import('getmac')]).then(([crypto, getmac]) => {
getmac.getMac((error, macAddress) => { try {
if (!error) { getmac.getMac((error, macAddress) => {
resolve(crypto.createHash('sha256').update(macAddress, 'utf8').digest('hex')); if (!error) {
} else { resolve(crypto.createHash('sha256').update(macAddress, 'utf8').digest('hex'));
resolve(undefined); } else {
} resolve(undefined);
}); }
} catch (err) { });
} catch (err) {
errors.onUnexpectedError(err);
resolve(undefined);
}
}, err => {
errors.onUnexpectedError(err); errors.onUnexpectedError(err);
resolve(undefined); resolve(undefined);
} });
}); });
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册