parent
5621d993e4
commit
279c4d048a
|
@ -9,6 +9,7 @@ import * as os from 'os';
|
|||
import * as cp from 'child_process';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as readline from 'readline';
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { ILaunchChannel } from 'vs/code/electron-main/launch';
|
||||
|
@ -16,8 +17,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
|
|||
import product from 'vs/platform/node/product';
|
||||
import { IRequestService } from 'vs/platform/request/node/request';
|
||||
import { IRequestContext } from 'vs/base/node/request';
|
||||
import { IChoiceService } from 'vs/platform/message/common/message';
|
||||
import Severity from 'vs/base/common/severity';
|
||||
|
||||
interface PostResult {
|
||||
readonly blob_id: string;
|
||||
|
@ -36,8 +35,7 @@ class Endpoint {
|
|||
|
||||
export async function uploadLogs(
|
||||
channel: ILaunchChannel,
|
||||
requestService: IRequestService,
|
||||
choiceService: IChoiceService
|
||||
requestService: IRequestService
|
||||
): TPromise<any> {
|
||||
const endpoint = Endpoint.getFromProduct();
|
||||
if (!endpoint) {
|
||||
|
@ -47,7 +45,7 @@ export async function uploadLogs(
|
|||
|
||||
const logsPath = await channel.call('get-logs-path', null);
|
||||
|
||||
if (await promptUserToConfirmLogUpload(logsPath, choiceService)) {
|
||||
if (await promptUserToConfirmLogUpload(logsPath)) {
|
||||
console.log(localize('beginUploading', 'Uploading...'));
|
||||
const outZip = await zipLogs(logsPath);
|
||||
const result = await postLogs(endpoint, outZip, requestService);
|
||||
|
@ -59,17 +57,23 @@ export async function uploadLogs(
|
|||
|
||||
async function promptUserToConfirmLogUpload(
|
||||
logsPath: string,
|
||||
choiceService: IChoiceService
|
||||
): Promise<boolean> {
|
||||
const message = localize('logUploadPromptHeader', 'Upload session logs to secure endpoint?')
|
||||
+ '\n\n' + localize('logUploadPromptBody', 'Please review your log files here: \'{0}\'', logsPath)
|
||||
+ '\n\n' + localize('logUploadPromptBodyDetails', 'Logs may contain personal information such as full paths and file contents.')
|
||||
+ '\n\n';
|
||||
const choice = await choiceService.choose(Severity.Info, message, [
|
||||
localize('logUploadPromptKey', 'I have reviewed my logs. Proceed with upload...'),
|
||||
localize('logUploadPromptCancel', 'Cancel'),
|
||||
], 1);
|
||||
return choice === 0;
|
||||
+ '\n\n' + localize('logUploadPromptKey', 'I have reviewed my logs (enter \'y\' to confirm upload)');
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
return new TPromise<boolean>(resolve =>
|
||||
rl.question(message,
|
||||
(answer: string) => {
|
||||
rl.close();
|
||||
resolve(answer && answer.trim()[0].toLowerCase() === 'y');
|
||||
}));
|
||||
}
|
||||
|
||||
async function postLogs(
|
||||
|
|
|
@ -109,7 +109,6 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
|
|||
const logService = accessor.get(ILogService);
|
||||
const environmentService = accessor.get(IEnvironmentService);
|
||||
const requestService = accessor.get(IRequestService);
|
||||
const choiceService = accessor.get(IChoiceService);
|
||||
|
||||
function allowSetForegroundWindow(service: LaunchChannelClient): TPromise<void> {
|
||||
let promise = TPromise.wrap<void>(void 0);
|
||||
|
@ -203,7 +202,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise<Server> {
|
|||
|
||||
// Log uploader
|
||||
if (environmentService.args['upload-logs']) {
|
||||
return uploadLogs(channel, requestService, choiceService)
|
||||
return uploadLogs(channel, requestService)
|
||||
.then(() => TPromise.wrapError(new ExpectedError()));
|
||||
}
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ export async function main(argv: string[]): TPromise<any> {
|
|||
|
||||
const processCallbacks: ((child: ChildProcess) => Thenable<any>)[] = [];
|
||||
|
||||
const verbose = args.verbose || args.status;
|
||||
const verbose = args.verbose || args.status || args['upload-logs'];
|
||||
if (verbose) {
|
||||
env['ELECTRON_ENABLE_LOGGING'] = '1';
|
||||
|
||||
|
@ -311,7 +311,9 @@ export async function main(argv: string[]): TPromise<any> {
|
|||
env
|
||||
};
|
||||
|
||||
if (!verbose) {
|
||||
if (args['upload-logs']) {
|
||||
options['stdio'] = [process.stdin, 'pipe', 'pipe'];
|
||||
} else if (!verbose) {
|
||||
options['stdio'] = 'ignore';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue