Featureful (#31)
* Fix loading within the CLI * Remove app * Remove promise handle * Add initial travis file * Add libxkbfile dependency * Add libxkbfile-dev * Add build script * Fix malformed bash statement * Remove yarn from script * Improve build script * Extract upx before usage * Only run upx if on linux * Ensure resource directory exists * Pack runnable binary * Export binary with platform * Improve build process * Install upx before running install script * Update typescript version before running nexe * Add os.release() function for multi-platform support * Update travis.yml to improve deployment * Add on CI * Update to v1.31.0 * Add libsecret * Update build target * Skip cleanup * Fix built-in extensions * Add basics for apps * Create custom DNS server * Fix forking within CLI. Fixes TS language features * Fix filename resolve * Fix default extensions path * Add custom dialog * Store workspace path * Remove outfiles * Cleanup * Always authed outside of CLI * Use location.host for client * Remove useless app interface * Remove debug file for building wordlist * Use chromes tcp host * Update patch * Build browser app before packaging * Replace all css containing file:// URLs, fix webviews * Fix save * Fix mkdir
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { readFile, writeFile } from "fs";
|
||||
import { readFile, writeFile, mkdir } from "fs";
|
||||
import * as path from "path";
|
||||
import { promisify } from "util";
|
||||
import { IDisposable } from "@coder/disposable";
|
||||
@@ -7,6 +7,8 @@ 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";
|
||||
import { client } from "@coder/vscode/src/client";
|
||||
import { IStorageService, WillSaveStateReason } from "vs/platform/storage/common/storage";
|
||||
|
||||
class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
||||
public readonly onDidChangeItemsExternal = Event.None;
|
||||
@@ -20,11 +22,9 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
||||
if (!navigator.sendBeacon) {
|
||||
throw new Error("cannot save state");
|
||||
}
|
||||
// TODO: Need to use navigator.sendBeacon instead of the web socket, or we
|
||||
// need to save when there is a change. Should we save as a sqlite3
|
||||
// database instead of JSON? Could send to the server the way the global
|
||||
// storage works. Or maybe fill `vscode-sqlite3` to do that.
|
||||
this.save();
|
||||
|
||||
this.triggerFlush(WillSaveStateReason.SHUTDOWN);
|
||||
navigator.sendBeacon(`/resource${this.path}`, this.content);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
||||
request.delete.forEach(key => this.items.delete(key));
|
||||
}
|
||||
|
||||
return Promise.resolve();
|
||||
return this.save();
|
||||
}
|
||||
|
||||
public close(): Promise<void> {
|
||||
@@ -69,13 +69,38 @@ class StorageDatabase implements workspaceStorage.IStorageDatabase {
|
||||
return Promise.resolve("ok");
|
||||
}
|
||||
|
||||
private save(): Promise<void> {
|
||||
private async save(): Promise<void> {
|
||||
try {
|
||||
await promisify(mkdir)(path.dirname(this.path));
|
||||
} catch (ex) {}
|
||||
|
||||
return promisify(writeFile)(this.path, this.content);
|
||||
}
|
||||
|
||||
private triggerFlush(reason: WillSaveStateReason = WillSaveStateReason.NONE): boolean {
|
||||
// tslint:disable-next-line:no-any
|
||||
const storageService = client.serviceCollection.get<IStorageService>(IStorageService) as any;
|
||||
if (reason === WillSaveStateReason.SHUTDOWN && storageService.close) {
|
||||
storageService.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
if (storageService._onWillSaveState) {
|
||||
storageService._onWillSaveState.fire({ reason });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private get content(): string {
|
||||
const json: { [key: string]: string } = {};
|
||||
this.items.forEach((value, key) => {
|
||||
json[key] = value;
|
||||
});
|
||||
|
||||
return promisify(writeFile)(this.path, JSON.stringify(json));
|
||||
return JSON.stringify(json);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user