提交 e9bddac7 编写于 作者: C Christof Marti

Set STABLE machineId in shared process (#20349)

上级 789fa539
......@@ -99,18 +99,24 @@ export function _futureMachineIdExperiment(): string {
let machineId: TPromise<string>;
export function getMachineId(): TPromise<string> {
return machineId || (machineId = new TPromise<string>(resolve => {
return machineId || (machineId = getStableMachineId()
.then(id => id || uuid.generateUuid())); // fallback, generate a UUID
}
let stableMachineId: TPromise<string>;
export function getStableMachineId(): TPromise<string> {
return stableMachineId || (stableMachineId = new TPromise<string>(resolve => {
try {
getmac.getMac((error, macAddress) => {
if (!error) {
resolve(crypto.createHash('sha256').update(macAddress, 'utf8').digest('hex'));
} else {
resolve(uuid.generateUuid()); // fallback, generate a UUID
resolve(undefined);
}
});
} catch (err) {
errors.onUnexpectedError(err);
resolve(uuid.generateUuid()); // fallback, generate a UUID
resolve(undefined);
}
}));
}
......@@ -7,7 +7,7 @@ import * as Platform from 'vs/base/common/platform';
import * as os from 'os';
import { TPromise } from 'vs/base/common/winjs.base';
import * as uuid from 'vs/base/common/uuid';
import { getMachineId } from 'vs/base/node/id';
import { getStableMachineId } from 'vs/base/node/id';
export function resolveCommonProperties(commit: string, version: string): TPromise<{ [name: string]: string; }> {
const result: { [name: string]: string; } = Object.create(null);
......@@ -17,7 +17,7 @@ export function resolveCommonProperties(commit: string, version: string): TPromi
result['version'] = version;
result['common.osVersion'] = os.release();
result['common.platform'] = Platform.Platform[Platform.platform];
const promise = getMachineId().then(value => result['common.machineId'] = value);
const promise = getStableMachineId().then(value => result['common.machineId'] = value);
// dynamic properties which value differs on each call
let seq = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册