From e66200eec8ab1944265bc6e857d755d4bd75b9d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Thu, 16 Nov 2023 00:26:30 +0100 Subject: [PATCH] feat: add ability to clean user data --- demo/index.html | 2 +- demo/src/setup.ts | 3 ++- src/service-override/files.ts | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/demo/index.html b/demo/index.html index babbe826..7bd97242 100644 --- a/demo/index.html +++ b/demo/index.html @@ -22,7 +22,7 @@

Editor

- +
diff --git a/demo/src/setup.ts b/demo/src/setup.ts index dd927a2d..80ba55dd 100644 --- a/demo/src/setup.ts +++ b/demo/src/setup.ts @@ -48,7 +48,7 @@ import { toCrossOriginWorker, toWorkerConfig } from './tools/workers' import defaultConfiguration from './user/configuration.json?raw' import defaultKeybindings from './user/keybindings.json?raw' -await createIndexedDBProviders() +const userDataProvider = await createIndexedDBProviders() // Workers export type WorkerLoader = () => Worker @@ -129,6 +129,7 @@ await initializeMonacoService({ StandaloneServices.get(ILogService).setLevel(LogLevel.Off) export async function clearStorage (): Promise { + await userDataProvider.reset() await (await getService(IStorageService) as BrowserStorageService).clear() } diff --git a/src/service-override/files.ts b/src/service-override/files.ts index 2549809c..9376aaaa 100644 --- a/src/service-override/files.ts +++ b/src/service-override/files.ts @@ -543,7 +543,7 @@ export async function initFile (scheme: string, file: URI, content: Uint8Array | /** * Can be used to replace memory providers by indexeddb providers before the fileService is initialized */ -export async function createIndexedDBProviders (): Promise { +export async function createIndexedDBProviders (): Promise { const userDataStore = 'vscode-userdata-store' const logsStore = 'vscode-logs-store' const handlesStore = 'vscode-filehandles-store' @@ -554,6 +554,8 @@ export async function createIndexedDBProviders (): Promise { const userDataProvider = new IndexedDBFileSystemProvider(Schemas.vscodeUserData, indexedDB, userDataStore, true) providers[Schemas.vscodeUserData] = userDataProvider + + return userDataProvider } /**