Skip to content

Commit 5d91cbe

Browse files
committed
Merge branch 'master' of github.com:codercom/vscode-online
2 parents 7466069 + 7edf797 commit 5d91cbe

8 files changed

Lines changed: 39 additions & 18 deletions

File tree

packages/ide/test/fs.test.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const fs = require("../src/fill/fs") as typeof import("fs");
1111

1212
describe("fs", () => {
1313
let i = 0;
14-
const coderDir = path.join(os.tmpdir(), "coder");
14+
const coderDir = path.join(os.tmpdir(), "coder", "fs");
1515
const testFile = path.join(__dirname, "fs.test.ts");
1616
const tmpFile = (): string => path.join(coderDir, `${i++}`);
1717
const createTmpFile = async (): Promise<string> => {
@@ -22,6 +22,13 @@ describe("fs", () => {
2222
};
2323

2424
beforeAll(async () => {
25+
try {
26+
await util.promisify(nativeFs.mkdir)(path.dirname(coderDir));
27+
} catch (error) {
28+
if (error.code !== "EEXIST") {
29+
throw error;
30+
}
31+
}
2532
await util.promisify(rimraf)(coderDir);
2633
await util.promisify(nativeFs.mkdir)(coderDir);
2734
});
@@ -332,7 +339,7 @@ describe("fs", () => {
332339
describe("mkdtemp", () => {
333340
it("should create temp dir", async () => {
334341
await expect(util.promisify(fs.mkdtemp)(coderDir + "/"))
335-
.resolves.toMatch(/^\/tmp\/coder\/[a-zA-Z0-9]{6}/);
342+
.resolves.toMatch(/^\/tmp\/coder\/fs\/[a-zA-Z0-9]{6}/);
336343
});
337344
});
338345

packages/ide/test/net.test.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,17 @@ const net = require("../src/fill/net") as typeof import("net");
1212

1313
describe("net", () => {
1414
let i = 0;
15-
const coderDir = path.join(os.tmpdir(), "coder");
15+
const coderDir = path.join(os.tmpdir(), "coder", "net");
1616
const tmpFile = (): string => path.join(coderDir, `socket.${i++}`);
1717

1818
beforeAll(async () => {
19+
try {
20+
await util.promisify(fs.mkdir)(path.dirname(coderDir));
21+
} catch (error) {
22+
if (error.code !== "EEXIST") {
23+
throw error;
24+
}
25+
}
1926
await util.promisify(rimraf)(coderDir);
2027
await util.promisify(fs.mkdir)(coderDir);
2128
});

packages/protocol/src/browser/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { logger, field } from "@coder/logger";
44
import { ReadWriteConnection, InitData, OperatingSystem, SharedProcessData } from "../common/connection";
55
import { Disposer, stringify, parse } from "../common/util";
66
import { NewEvalMessage, ServerMessage, EvalDoneMessage, EvalFailedMessage, ClientMessage, WorkingInitMessage, EvalEventMessage } from "../proto";
7-
import { ActiveEval } from "./command";
7+
import { ActiveEval } from "./evaluate";
88

99
/**
1010
* Client accepts an arbitrary connection intended to communicate with the Server.

packages/protocol/src/common/util.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type IEncodingOptionsCallback = IEncodingOptions | ((err: NodeJS.ErrnoExc
3131
*/
3232
export const stringify = (arg: any): string => { // tslint:disable-line no-any
3333
if (arg instanceof Error) {
34+
// Errors don't stringify at all. They just become "{}".
3435
return JSON.stringify({
3536
type: "Error",
3637
data: {
@@ -39,6 +40,15 @@ export const stringify = (arg: any): string => { // tslint:disable-line no-any
3940
stack: arg.stack,
4041
},
4142
});
43+
} else if (arg instanceof Uint8Array) {
44+
// With stringify, these get turned into objects with each index becoming a
45+
// key for some reason. Then trying to do something like write that data
46+
// results in [object Object] being written. Stringify them like a Buffer
47+
// instead.
48+
return JSON.stringify({
49+
type: "Buffer",
50+
data: Array.from(arg),
51+
});
4252
}
4353

4454
return JSON.stringify(arg);

packages/protocol/src/node/evaluate.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ export interface ActiveEvaluation {
1212

1313
declare var __non_webpack_require__: typeof require;
1414
export const evaluate = (connection: SendableConnection, message: NewEvalMessage, onDispose: () => void): ActiveEvaluation | void => {
15-
const argStr: string[] = [];
16-
message.getArgsList().forEach((value) => {
17-
argStr.push(value);
18-
});
19-
2015
/**
2116
* Send the response and call onDispose.
2217
*/
@@ -94,11 +89,12 @@ export const evaluate = (connection: SendableConnection, message: NewEvalMessage
9489
process: {
9590
env: process.env,
9691
},
92+
args: message.getArgsList().map(parse),
9793
};
9894

9995
let value: any; // tslint:disable-line no-any
10096
try {
101-
const code = `(${message.getFunction()})(${eventEmitter ? "eventEmitter, " : ""}${argStr.join(",")});`;
97+
const code = `(${message.getFunction()})(${eventEmitter ? "eventEmitter, " : ""}...args);`;
10298
value = vm.runInNewContext(code, sandbox, {
10399
// If the code takes longer than this to return, it is killed and throws.
104100
timeout: message.getTimeout() || 15000,

packages/vscode/src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ export class Client extends IdeClient {
4141
return this._builtInExtensionsDirectory;
4242
}
4343

44-
public async handleExternalDrop(target: ExplorerItem | ExplorerModel, originalEvent: DragMouseEvent): Promise<void> {
44+
public async handleExternalDrop(target: ExplorerItem | ExplorerModel, originalEvent: DragEvent): Promise<void> {
4545
await this.upload.uploadDropped(
46-
originalEvent.browserEvent as DragEvent,
46+
originalEvent,
4747
(target instanceof ExplorerItem ? target : target.roots[0]).resource,
4848
);
4949
}

packages/vscode/src/fill/storageDatabase.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
1414
public readonly onDidChangeItemsExternal = Event.None;
1515
private readonly items = new Map<string, string>();
1616
private fetched: boolean = false;
17+
private readonly path: string;
1718

18-
public constructor(private readonly path: string) {
19-
path = path.replace(/\.vscdb$/, ".json");
20-
logger.debug("Setting up storage", field("path", path));
19+
public constructor(path: string) {
20+
this.path = path.replace(/\.vscdb$/, ".json");
21+
logger.debug("Setting up storage", field("path", this.path));
2122
window.addEventListener("unload", () => {
2223
if (!navigator.sendBeacon) {
2324
throw new Error("cannot save state");
@@ -39,7 +40,7 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
3940
this.items.set(key, json[key]);
4041
});
4142
} catch (error) {
42-
if (error.code && error.code !== "ENOENT") {
43+
if (error.code !== "ENOENT") {
4344
throw error;
4445
}
4546
}

scripts/vscode.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ index 81954344b9..2bdce9603e 100644
129129
- if (!fs.existsSync(this.adapterExecutable.command)) {
130130
+ if (!(await require("util").promisify(fs.exists)(this.adapterExecutable.command))) {
131131
diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
132-
index e66f74f034..aca6f509b0 100644
132+
index e66f74f034..759ffe0cef 100644
133133
--- a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
134134
+++ b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts
135135
@@ -586,0 +587 @@ export class FileDragAndDrop implements ITreeDragAndDrop<ExplorerItem> {
136-
+ return (require('vs/../../../../packages/vscode') as typeof import ('vs/../../../../packages/vscode')).client.handleExternalDrop(target, originalEvent as any);
136+
+ return (require('vs/../../../../packages/vscode') as typeof import('vs/../../../../packages/vscode')).client.handleExternalDrop(target, originalEvent);
137137
diff --git a/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts b/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts
138138
index 4015c9cd5d..bebdb25f6c 100644
139139
--- a/src/vs/workbench/parts/logs/electron-browser/logs.contribution.ts

0 commit comments

Comments
 (0)