mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-13 19:48:37 -05:00
Merge from vscode 2c306f762bf9c3db82dc06c7afaa56ef46d72f79 (#14050)
* Merge from vscode 2c306f762bf9c3db82dc06c7afaa56ef46d72f79 * Fix breaks * Extension management fixes * Fix breaks in windows bundling * Fix/skip failing tests * Update distro * Add clear to nuget.config * Add hygiene task * Bump distro * Fix hygiene issue * Add build to hygiene exclusion * Update distro * Update hygiene * Hygiene exclusions * Update tsconfig * Bump distro for server breaks * Update build config * Update darwin path * Add done calls to notebook tests * Skip failing tests * Disable smoke tests
This commit is contained in:
@@ -7,8 +7,8 @@ import * as fs from 'fs';
|
||||
import * as crypto from 'crypto';
|
||||
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) => {
|
||||
export async function checksum(path: string, sha1hash: string | undefined): Promise<void> {
|
||||
const checksumPromise = new Promise<string | undefined>((resolve, reject) => {
|
||||
const input = fs.createReadStream(path);
|
||||
const hash = crypto.createHash('sha1');
|
||||
input.pipe(hash);
|
||||
@@ -18,9 +18,9 @@ export function checksum(path: string, sha1hash: string | undefined): Promise<vo
|
||||
hash.removeAllListeners();
|
||||
|
||||
if (err) {
|
||||
e(err);
|
||||
reject(err);
|
||||
} else {
|
||||
c(result);
|
||||
resolve(result);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -30,11 +30,9 @@ export function checksum(path: string, sha1hash: string | undefined): Promise<vo
|
||||
hash.once('data', (data: Buffer) => done(undefined, data.toString('hex')));
|
||||
});
|
||||
|
||||
return promise.then(hash => {
|
||||
if (hash !== sha1hash) {
|
||||
return Promise.reject(new Error('Hash mismatch'));
|
||||
}
|
||||
const hash = await checksumPromise;
|
||||
|
||||
return Promise.resolve();
|
||||
});
|
||||
if (hash !== sha1hash) {
|
||||
throw new Error('Hash mismatch');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import { readdirSync } from 'vs/base/node/pfs';
|
||||
import { promisify } from 'util';
|
||||
|
||||
/**
|
||||
* Copied from: https://github.com/Microsoft/vscode-node-debug/blob/master/src/node/pathUtilities.ts#L83
|
||||
* Copied from: https://github.com/microsoft/vscode-node-debug/blob/master/src/node/pathUtilities.ts#L83
|
||||
*
|
||||
* Given an absolute, normalized, and existing file path 'realcase' returns the exact path that the file has on disk.
|
||||
* On a case insensitive file system, the returned path might differ from the original path by character casing.
|
||||
@@ -88,4 +88,4 @@ export function realpathSync(path: string): string {
|
||||
|
||||
function normalizePath(path: string): string {
|
||||
return rtrim(normalize(path), sep);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,13 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { exec } from 'child_process';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
const cmdline = {
|
||||
windows: 'getmac.exe',
|
||||
unix: '/sbin/ifconfig -a || /sbin/ip link'
|
||||
};
|
||||
import { networkInterfaces } from 'os';
|
||||
|
||||
const invalidMacAddresses = new Set([
|
||||
'00:00:00:00:00:00',
|
||||
@@ -39,23 +33,16 @@ export function getMac(): Promise<string> {
|
||||
function doGetMac(): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
exec(isWindows ? cmdline.windows : cmdline.unix, { timeout: 10000 }, (err, stdout, stdin) => {
|
||||
if (err) {
|
||||
return reject(`Unable to retrieve mac address (${err.toString()})`);
|
||||
} else {
|
||||
const regex = /(?:[a-f\d]{2}[:\-]){5}[a-f\d]{2}/gi;
|
||||
|
||||
let match;
|
||||
while ((match = regex.exec(stdout)) !== null) {
|
||||
const macAddressCandidate = match[0];
|
||||
if (validateMacAddress(macAddressCandidate)) {
|
||||
return resolve(macAddressCandidate);
|
||||
}
|
||||
const ifaces = networkInterfaces();
|
||||
for (const [, infos] of Object.entries(ifaces)) {
|
||||
for (const info of infos) {
|
||||
if (validateMacAddress(info.mac)) {
|
||||
return resolve(info.mac);
|
||||
}
|
||||
|
||||
return reject('Unable to retrieve mac address (unexpected format)');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
reject('Unable to retrieve mac address (unexpected format)');
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
@@ -3,14 +3,9 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
|
||||
interface IPaths {
|
||||
getAppDataPath(platform: string): string;
|
||||
getDefaultUserDataPath(platform: string): string;
|
||||
}
|
||||
const pathsPath = FileAccess.asFileUri('paths', require).fsPath;
|
||||
const paths = require.__$__nodeRequire<{ getDefaultUserDataPath(): string }>(pathsPath);
|
||||
|
||||
const pathsPath = getPathFromAmdModule(require, 'paths');
|
||||
const paths = require.__$__nodeRequire<IPaths>(pathsPath);
|
||||
export const getAppDataPath = paths.getAppDataPath;
|
||||
export const getDefaultUserDataPath = paths.getDefaultUserDataPath;
|
||||
|
||||
@@ -14,7 +14,7 @@ import { isRootOrDriveLetter } from 'vs/base/common/extpath';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { normalizeNFC } from 'vs/base/common/normalization';
|
||||
|
||||
// See https://github.com/Microsoft/vscode/issues/30180
|
||||
// See https://github.com/microsoft/vscode/issues/30180
|
||||
const WIN32_MAX_FILE_SIZE = 300 * 1024 * 1024; // 300 MB
|
||||
const GENERAL_MAX_FILE_SIZE = 16 * 1024 * 1024 * 1024; // 16 GB
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import * as extpath from 'vs/base/common/extpath';
|
||||
import * as Platform from 'vs/base/common/platform';
|
||||
import { LineDecoder } from 'vs/base/node/decoder';
|
||||
import { CommandOptions, ForkOptions, SuccessData, Source, TerminateResponse, TerminateResponseCode, Executable } from 'vs/base/common/processes';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
export { CommandOptions, ForkOptions, SuccessData, Source, TerminateResponse, TerminateResponseCode };
|
||||
|
||||
export type ValueCallback<T> = (value: T | Promise<T>) => void;
|
||||
@@ -67,7 +67,7 @@ function terminateProcess(process: cp.ChildProcess, cwd?: string): Promise<Termi
|
||||
}
|
||||
} else if (Platform.isLinux || Platform.isMacintosh) {
|
||||
try {
|
||||
const cmd = getPathFromAmdModule(require, 'vs/base/node/terminateProcess.sh');
|
||||
const cmd = FileAccess.asFileUri('vs/base/node/terminateProcess.sh', require).fsPath;
|
||||
return new Promise((resolve, reject) => {
|
||||
cp.execFile(cmd, [process.pid.toString()], { encoding: 'utf8', shell: true } as cp.ExecFileOptions, (err, stdout, stderr) => {
|
||||
if (err) {
|
||||
@@ -86,8 +86,8 @@ function terminateProcess(process: cp.ChildProcess, cwd?: string): Promise<Termi
|
||||
return Promise.resolve({ success: true });
|
||||
}
|
||||
|
||||
export function getWindowsShell(): string {
|
||||
return process.env['comspec'] || 'cmd.exe';
|
||||
export function getWindowsShell(environment: Platform.IProcessEnvironment = process.env as Platform.IProcessEnvironment): string {
|
||||
return environment['comspec'] || 'cmd.exe';
|
||||
}
|
||||
|
||||
export abstract class AbstractProcess<TProgressData> {
|
||||
@@ -318,16 +318,16 @@ export abstract class AbstractProcess<TProgressData> {
|
||||
}
|
||||
|
||||
private useExec(): Promise<boolean> {
|
||||
return new Promise<boolean>((c, e) => {
|
||||
return new Promise<boolean>(resolve => {
|
||||
if (!this.shell || !Platform.isWindows) {
|
||||
return c(false);
|
||||
return resolve(false);
|
||||
}
|
||||
const cmdShell = cp.spawn(getWindowsShell(), ['/s', '/c']);
|
||||
cmdShell.on('error', (error: Error) => {
|
||||
return c(true);
|
||||
return resolve(true);
|
||||
});
|
||||
cmdShell.on('exit', (data: any) => {
|
||||
return c(false);
|
||||
return resolve(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
import { exec } from 'child_process';
|
||||
import { ProcessItem } from 'vs/base/common/processes';
|
||||
import { getPathFromAmdModule } from 'vs/base/common/amd';
|
||||
import { FileAccess } from 'vs/base/common/network';
|
||||
|
||||
export function listProcesses(rootPid: number): Promise<ProcessItem> {
|
||||
|
||||
@@ -180,7 +180,7 @@ export function listProcesses(rootPid: number): Promise<ProcessItem> {
|
||||
// The cpu usage value reported on Linux is the average over the process lifetime,
|
||||
// recalculate the usage over a one second interval
|
||||
// JSON.stringify is needed to escape spaces, https://github.com/nodejs/node/issues/6803
|
||||
let cmd = JSON.stringify(getPathFromAmdModule(require, 'vs/base/node/cpuUsage.sh'));
|
||||
let cmd = JSON.stringify(FileAccess.asFileUri('vs/base/node/cpuUsage.sh', require).fsPath);
|
||||
cmd += ' ' + pids.join(' ');
|
||||
|
||||
exec(cmd, {}, (err, stdout, stderr) => {
|
||||
@@ -208,7 +208,7 @@ export function listProcesses(rootPid: number): Promise<ProcessItem> {
|
||||
if (process.platform !== 'linux') {
|
||||
reject(err || new Error(stderr.toString()));
|
||||
} else {
|
||||
const cmd = JSON.stringify(getPathFromAmdModule(require, 'vs/base/node/ps.sh'));
|
||||
const cmd = JSON.stringify(FileAccess.asFileUri('vs/base/node/ps.sh', require).fsPath);
|
||||
exec(cmd, {}, (err, stdout, stderr) => {
|
||||
if (err || stderr) {
|
||||
reject(err || new Error(stderr.toString()));
|
||||
|
||||
@@ -58,7 +58,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha
|
||||
|
||||
// Normalize file name
|
||||
let changedFileName: string = '';
|
||||
if (raw) { // https://github.com/Microsoft/vscode/issues/38191
|
||||
if (raw) { // https://github.com/microsoft/vscode/issues/38191
|
||||
changedFileName = raw.toString();
|
||||
if (isMacintosh) {
|
||||
// Mac: uses NFD unicode form on disk, but we want NFC
|
||||
|
||||
@@ -73,7 +73,7 @@ function toExtractError(err: Error): ExtractError {
|
||||
function extractEntry(stream: Readable, fileName: string, mode: number, targetPath: string, options: IOptions, token: CancellationToken): Promise<void> {
|
||||
const dirName = path.dirname(fileName);
|
||||
const targetDirName = path.join(targetPath, dirName);
|
||||
if (targetDirName.indexOf(targetPath) !== 0) {
|
||||
if (!targetDirName.startsWith(targetPath)) {
|
||||
return Promise.reject(new Error(nls.localize('invalid file', "Error extracting {0}. Invalid file.", fileName)));
|
||||
}
|
||||
const targetFileName = path.join(targetPath, fileName);
|
||||
|
||||
Reference in New Issue
Block a user