Archived
1
0

Implement global storage database channel client

Since our channels don't actually go back to the server or anything like
that. Could be something to look into though.
This commit is contained in:
Asher 2019-01-22 14:54:51 -06:00 committed by Kyle Carberry
parent cba8196c19
commit 15bfd15742
No known key found for this signature in database
GPG Key ID: A0409BDB6B0B3EDB
2 changed files with 26 additions and 26 deletions

View File

@ -1,15 +1,22 @@
import { readFile, writeFile } from "fs";
import * as path from "path";
import { promisify } from "util";
import { IDisposable } from "@coder/disposable";
import { Event } from "vs/base/common/event";
import * as storage from "vs/base/node/storage";
import * as workspaceStorage from "vs/base/node/storage";
import * as globalStorage from "vs/platform/storage/node/storageIpc";
import * as paths from "./paths";
import { logger, field } from "@coder/logger";
export class StorageDatabase implements storage.IStorageDatabase {
export class StorageDatabase implements workspaceStorage.IStorageDatabase {
public readonly onDidChangeItemsExternal = Event.None;
private items = new Map<string, string>();
private fetched: boolean = false;
public constructor(private readonly path: string) {
path = path.replace(/\.vscdb$/, ".json");
logger.debug("Setting up storage", field("path", path));
window.addEventListener("unload", () => {
if (!navigator.sendBeacon) {
throw new Error("cannot save state");
@ -43,7 +50,7 @@ export class StorageDatabase implements storage.IStorageDatabase {
return this.items;
}
public updateItems(request: storage.IUpdateRequest): Promise<void> {
public updateItems(request: workspaceStorage.IUpdateRequest): Promise<void> {
if (request.insert) {
request.insert.forEach((value, key) => this.items.set(key, value));
}
@ -74,5 +81,19 @@ export class StorageDatabase implements storage.IStorageDatabase {
}
export class GlobalStorageDatabase extends StorageDatabase implements IDisposable {
public constructor() {
super(path.join(paths.getAppDataPath(), "globalStorage", "state.vscdb"));
}
public dispose(): void {
// Nothing to do.
}
}
// @ts-ignore
storage.SQLiteStorageDatabase = StorageDatabase;
workspaceStorage.SQLiteStorageDatabase = StorageDatabase;
// @ts-ignore
globalStorage.GlobalStorageDatabaseChannelClient = GlobalStorageDatabase;

View File

@ -47,27 +47,6 @@ index 2bf7fe37d7..81cc668f12 100644
}
catch (err) {
errorback(err);
diff --git a/src/vs/platform/storage/node/storageService.ts b/src/vs/platform/storage/node/storageService.ts
index 9e6a94bbd2..9e7f9cb595 100644
--- a/src/vs/platform/storage/node/storageService.ts
+++ b/src/vs/platform/storage/node/storageService.ts
@@ -89,6 +89,9 @@ export class StorageService extends Disposable implements IStorageService {
private initializeGlobalStorage(): Thenable<void> {
mark('willInitGlobalStorage');
+ // TODO: shouldn't reject
+ return Promise.reject(new Error("nope"));
+
return this.globalStorage.init().then(() => {
mark('didInitGlobalStorage');
}, error => {
@@ -605,4 +608,4 @@ export class DelegatingStorageService extends Disposable implements IStorageServ
private convertScope(scope: StorageScope): StorageLegacyScope {
return scope === StorageScope.GLOBAL ? StorageLegacyScope.GLOBAL : StorageLegacyScope.WORKSPACE;
}
-}
\ No newline at end of file
+}
diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts
index a43d63aa51..4c6df2fcd9 100644
--- a/src/vs/workbench/electron-browser/main.ts