mirror of
https://git.tuxpa.in/a/code-server.git
synced 2024-12-26 12:15:26 +00:00
Merge branch 'master' of github.com:codercom/vscode-online
This commit is contained in:
commit
5d91cbea9d
@ -11,7 +11,7 @@ const fs = require("../src/fill/fs") as typeof import("fs");
|
|||||||
|
|
||||||
describe("fs", () => {
|
describe("fs", () => {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const coderDir = path.join(os.tmpdir(), "coder");
|
const coderDir = path.join(os.tmpdir(), "coder", "fs");
|
||||||
const testFile = path.join(__dirname, "fs.test.ts");
|
const testFile = path.join(__dirname, "fs.test.ts");
|
||||||
const tmpFile = (): string => path.join(coderDir, `${i++}`);
|
const tmpFile = (): string => path.join(coderDir, `${i++}`);
|
||||||
const createTmpFile = async (): Promise<string> => {
|
const createTmpFile = async (): Promise<string> => {
|
||||||
@ -22,6 +22,13 @@ describe("fs", () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
try {
|
||||||
|
await util.promisify(nativeFs.mkdir)(path.dirname(coderDir));
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code !== "EEXIST") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
await util.promisify(rimraf)(coderDir);
|
await util.promisify(rimraf)(coderDir);
|
||||||
await util.promisify(nativeFs.mkdir)(coderDir);
|
await util.promisify(nativeFs.mkdir)(coderDir);
|
||||||
});
|
});
|
||||||
@ -332,7 +339,7 @@ describe("fs", () => {
|
|||||||
describe("mkdtemp", () => {
|
describe("mkdtemp", () => {
|
||||||
it("should create temp dir", async () => {
|
it("should create temp dir", async () => {
|
||||||
await expect(util.promisify(fs.mkdtemp)(coderDir + "/"))
|
await expect(util.promisify(fs.mkdtemp)(coderDir + "/"))
|
||||||
.resolves.toMatch(/^\/tmp\/coder\/[a-zA-Z0-9]{6}/);
|
.resolves.toMatch(/^\/tmp\/coder\/fs\/[a-zA-Z0-9]{6}/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -12,10 +12,17 @@ const net = require("../src/fill/net") as typeof import("net");
|
|||||||
|
|
||||||
describe("net", () => {
|
describe("net", () => {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
const coderDir = path.join(os.tmpdir(), "coder");
|
const coderDir = path.join(os.tmpdir(), "coder", "net");
|
||||||
const tmpFile = (): string => path.join(coderDir, `socket.${i++}`);
|
const tmpFile = (): string => path.join(coderDir, `socket.${i++}`);
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
|
try {
|
||||||
|
await util.promisify(fs.mkdir)(path.dirname(coderDir));
|
||||||
|
} catch (error) {
|
||||||
|
if (error.code !== "EEXIST") {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
await util.promisify(rimraf)(coderDir);
|
await util.promisify(rimraf)(coderDir);
|
||||||
await util.promisify(fs.mkdir)(coderDir);
|
await util.promisify(fs.mkdir)(coderDir);
|
||||||
});
|
});
|
||||||
|
@ -4,7 +4,7 @@ import { logger, field } from "@coder/logger";
|
|||||||
import { ReadWriteConnection, InitData, OperatingSystem, SharedProcessData } from "../common/connection";
|
import { ReadWriteConnection, InitData, OperatingSystem, SharedProcessData } from "../common/connection";
|
||||||
import { Disposer, stringify, parse } from "../common/util";
|
import { Disposer, stringify, parse } from "../common/util";
|
||||||
import { NewEvalMessage, ServerMessage, EvalDoneMessage, EvalFailedMessage, ClientMessage, WorkingInitMessage, EvalEventMessage } from "../proto";
|
import { NewEvalMessage, ServerMessage, EvalDoneMessage, EvalFailedMessage, ClientMessage, WorkingInitMessage, EvalEventMessage } from "../proto";
|
||||||
import { ActiveEval } from "./command";
|
import { ActiveEval } from "./evaluate";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client accepts an arbitrary connection intended to communicate with the Server.
|
* Client accepts an arbitrary connection intended to communicate with the Server.
|
||||||
|
@ -31,6 +31,7 @@ export type IEncodingOptionsCallback = IEncodingOptions | ((err: NodeJS.ErrnoExc
|
|||||||
*/
|
*/
|
||||||
export const stringify = (arg: any): string => { // tslint:disable-line no-any
|
export const stringify = (arg: any): string => { // tslint:disable-line no-any
|
||||||
if (arg instanceof Error) {
|
if (arg instanceof Error) {
|
||||||
|
// Errors don't stringify at all. They just become "{}".
|
||||||
return JSON.stringify({
|
return JSON.stringify({
|
||||||
type: "Error",
|
type: "Error",
|
||||||
data: {
|
data: {
|
||||||
@ -39,6 +40,15 @@ export const stringify = (arg: any): string => { // tslint:disable-line no-any
|
|||||||
stack: arg.stack,
|
stack: arg.stack,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
} else if (arg instanceof Uint8Array) {
|
||||||
|
// With stringify, these get turned into objects with each index becoming a
|
||||||
|
// key for some reason. Then trying to do something like write that data
|
||||||
|
// results in [object Object] being written. Stringify them like a Buffer
|
||||||
|
// instead.
|
||||||
|
return JSON.stringify({
|
||||||
|
type: "Buffer",
|
||||||
|
data: Array.from(arg),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return JSON.stringify(arg);
|
return JSON.stringify(arg);
|
||||||
|
@ -12,11 +12,6 @@ export interface ActiveEvaluation {
|
|||||||
|
|
||||||
declare var __non_webpack_require__: typeof require;
|
declare var __non_webpack_require__: typeof require;
|
||||||
export const evaluate = (connection: SendableConnection, message: NewEvalMessage, onDispose: () => void): ActiveEvaluation | void => {
|
export const evaluate = (connection: SendableConnection, message: NewEvalMessage, onDispose: () => void): ActiveEvaluation | void => {
|
||||||
const argStr: string[] = [];
|
|
||||||
message.getArgsList().forEach((value) => {
|
|
||||||
argStr.push(value);
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the response and call onDispose.
|
* Send the response and call onDispose.
|
||||||
*/
|
*/
|
||||||
@ -94,11 +89,12 @@ export const evaluate = (connection: SendableConnection, message: NewEvalMessage
|
|||||||
process: {
|
process: {
|
||||||
env: process.env,
|
env: process.env,
|
||||||
},
|
},
|
||||||
|
args: message.getArgsList().map(parse),
|
||||||
};
|
};
|
||||||
|
|
||||||
let value: any; // tslint:disable-line no-any
|
let value: any; // tslint:disable-line no-any
|
||||||
try {
|
try {
|
||||||
const code = `(${message.getFunction()})(${eventEmitter ? "eventEmitter, " : ""}${argStr.join(",")});`;
|
const code = `(${message.getFunction()})(${eventEmitter ? "eventEmitter, " : ""}...args);`;
|
||||||
value = vm.runInNewContext(code, sandbox, {
|
value = vm.runInNewContext(code, sandbox, {
|
||||||
// If the code takes longer than this to return, it is killed and throws.
|
// If the code takes longer than this to return, it is killed and throws.
|
||||||
timeout: message.getTimeout() || 15000,
|
timeout: message.getTimeout() || 15000,
|
||||||
|
@ -41,9 +41,9 @@ export class Client extends IdeClient {
|
|||||||
return this._builtInExtensionsDirectory;
|
return this._builtInExtensionsDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async handleExternalDrop(target: ExplorerItem | ExplorerModel, originalEvent: DragMouseEvent): Promise<void> {
|
public async handleExternalDrop(target: ExplorerItem | ExplorerModel, originalEvent: DragEvent): Promise<void> {
|
||||||
await this.upload.uploadDropped(
|
await this.upload.uploadDropped(
|
||||||
originalEvent.browserEvent as DragEvent,
|
originalEvent,
|
||||||
(target instanceof ExplorerItem ? target : target.roots[0]).resource,
|
(target instanceof ExplorerItem ? target : target.roots[0]).resource,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,11 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
|||||||
public readonly onDidChangeItemsExternal = Event.None;
|
public readonly onDidChangeItemsExternal = Event.None;
|
||||||
private readonly items = new Map<string, string>();
|
private readonly items = new Map<string, string>();
|
||||||
private fetched: boolean = false;
|
private fetched: boolean = false;
|
||||||
|
private readonly path: string;
|
||||||
|
|
||||||
public constructor(private readonly path: string) {
|
public constructor(path: string) {
|
||||||
path = path.replace(/\.vscdb$/, ".json");
|
this.path = path.replace(/\.vscdb$/, ".json");
|
||||||
logger.debug("Setting up storage", field("path", path));
|
logger.debug("Setting up storage", field("path", this.path));
|
||||||
window.addEventListener("unload", () => {
|
window.addEventListener("unload", () => {
|
||||||
if (!navigator.sendBeacon) {
|
if (!navigator.sendBeacon) {
|
||||||
throw new Error("cannot save state");
|
throw new Error("cannot save state");
|
||||||
@ -39,7 +40,7 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
|||||||
this.items.set(key, json[key]);
|
this.items.set(key, json[key]);
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code && error.code !== "ENOENT") {
|
if (error.code !== "ENOENT") {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,11 +129,11 @@ index 81954344b9..2bdce9603e 100644
|
|||||||
- if (!fs.existsSync(this.adapterExecutable.command)) {
|
- if (!fs.existsSync(this.adapterExecutable.command)) {
|
||||||
+ if (!(await require("util").promisify(fs.exists)(this.adapterExecutable.command))) {
|
+ if (!(await require("util").promisify(fs.exists)(this.adapterExecutable.command))) {
|
||||||
diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
|
diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
|
||||||
index e66f74f034..aca6f509b0 100644
|
index e66f74f034..759ffe0cef 100644
|
||||||
--- a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
|
--- a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
|
||||||
+++ b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
|
+++ b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
|
||||||
@@ -586,0 +587 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
|
@@ -586,0 +587 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
|
||||||
+ return (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.handleExternalDrop(target, originalEvent as any);
|
+ return (require('vs/../../../../packages/vscode') as typeof import('vs/../../../../packages/vscode')).client.handleExternalDrop(target, originalEvent);
|
||||||
diff --git a/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts b/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts
|
diff --git a/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts b/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts
|
||||||
index 4015c9cd5d..bebdb25f6c 100644
|
index 4015c9cd5d..bebdb25f6c 100644
|
||||||
--- a/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts
|
--- a/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts
|
||||||
|
Loading…
Reference in New Issue
Block a user