Fix issues with configuration directories
- Move the old data directory if possible. - Fix extension path to not use a hard-coded path and instead use the data directory. - Create every part of the path during startup. - Create each path when a connection is made as well in case they are deleted while the server is running. - Create every part of the path before saving settings or writing a file using the resource endpoint.
This commit is contained in:
@ -4,6 +4,7 @@ import Severity from "vs/base/common/severity";
|
||||
import { INotificationService } from "vs/platform/notification/common/notification";
|
||||
import { IStatusbarService, StatusbarAlignment } from "vs/platform/statusbar/common/statusbar";
|
||||
import * as paths from "./fill/paths";
|
||||
import product from "./fill/product";
|
||||
import "./vscode.scss";
|
||||
import { MenuId, MenuRegistry } from "vs/platform/actions/common/actions";
|
||||
import { CommandsRegistry } from "vs/platform/commands/common/commands";
|
||||
@ -14,6 +15,7 @@ class VSClient extends IdeClient {
|
||||
protected initialize(): Promise<void> {
|
||||
return this.task("Start workbench", 1000, async (data, sharedData) => {
|
||||
paths._paths.initialize(data, sharedData);
|
||||
product.initialize(data);
|
||||
process.env.SHELL = data.shell;
|
||||
// At this point everything should be filled, including `os`. `os` also
|
||||
// relies on `initData` but it listens first so it initialize before this
|
||||
|
@ -1,3 +1,4 @@
|
||||
import * as path from "path";
|
||||
import * as paths from "./paths";
|
||||
import * as environment from "vs/platform/environment/node/environmentService";
|
||||
|
||||
@ -5,6 +6,10 @@ export class EnvironmentService extends environment.EnvironmentService {
|
||||
public get sharedIPCHandle(): string {
|
||||
return paths.getSocketPath() || super.sharedIPCHandle;
|
||||
}
|
||||
|
||||
public get extensionsPath(): string {
|
||||
return path.join(paths.getAppDataPath(), "extensions");
|
||||
}
|
||||
}
|
||||
|
||||
const target = environment as typeof environment;
|
||||
|
@ -1,26 +1,37 @@
|
||||
import { InitData } from "@coder/protocol";
|
||||
import { IProductConfiguration } from "vs/platform/product/node/product";
|
||||
|
||||
const product = {
|
||||
nameShort: "code-server",
|
||||
nameLong: "code-server",
|
||||
dataFolderName: ".code-server",
|
||||
extensionsGallery: {
|
||||
class Product implements IProductConfiguration {
|
||||
public nameShort = "code-server";
|
||||
public nameLong = "code-server";
|
||||
|
||||
private _dataFolderName: string | undefined;
|
||||
public get dataFolderName(): string {
|
||||
if (!this._dataFolderName) {
|
||||
throw new Error("trying to access data folder name before it has been set");
|
||||
}
|
||||
|
||||
return this._dataFolderName;
|
||||
}
|
||||
|
||||
public extensionsGallery = {
|
||||
serviceUrl: global && global.process && global.process.env.SERVICE_URL
|
||||
|| process.env.SERVICE_URL
|
||||
|| "https://v1.extapi.coder.com",
|
||||
},
|
||||
extensionExecutionEnvironments: {
|
||||
};
|
||||
|
||||
public extensionExecutionEnvironments = {
|
||||
"wayou.vscode-todo-highlight": "worker",
|
||||
"vscodevim.vim": "worker",
|
||||
"coenraads.bracket-pair-colorizer": "worker",
|
||||
},
|
||||
fetchUrl: "",
|
||||
} as IProductConfiguration;
|
||||
};
|
||||
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
product.nameShort += ' Dev';
|
||||
product.nameLong += ' Dev';
|
||||
product.dataFolderName += '-dev';
|
||||
public fetchUrl = "";
|
||||
|
||||
public initialize(_data: InitData): void {
|
||||
// Nothing at the moment; dataFolderName isn't used since we override the
|
||||
// extension path.
|
||||
}
|
||||
}
|
||||
|
||||
export default product;
|
||||
export default new Product();
|
||||
|
@ -1,8 +1,9 @@
|
||||
import { readFile, writeFile, mkdir } from "fs";
|
||||
import { readFile, writeFile } from "fs";
|
||||
import * as path from "path";
|
||||
import { promisify } from "util";
|
||||
import { IDisposable } from "@coder/disposable";
|
||||
import { logger, field } from "@coder/logger";
|
||||
import { mkdirP } from "@coder/protocol";
|
||||
import { Event } from "vs/base/common/event";
|
||||
import * as workspaceStorage from "vs/base/node/storage";
|
||||
import * as globalStorage from "vs/platform/storage/node/storageIpc";
|
||||
@ -77,9 +78,7 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
||||
}
|
||||
|
||||
private async save(): Promise<void> {
|
||||
try {
|
||||
await promisify(mkdir)(path.dirname(this.path));
|
||||
} catch (ex) {}
|
||||
await mkdirP(path.dirname(this.path));
|
||||
|
||||
return promisify(writeFile)(this.path, this.content);
|
||||
}
|
||||
|
Reference in New Issue
Block a user