Skip to content

Commit

Permalink
feat: add ability to clean user data
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Nov 15, 2023
1 parent ec74e05 commit e66200e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h1>Editor</h1>
<button id="run">Run with debugger</button>
<button id="filesystem">Attach filesystem</button>
<button id="customEditorPanel">Open custom editor panel</button>
<button id="clearStorage">Clear storage</button>
<button id="clearStorage">Clear user data</button>
<br />
<button id="togglePanel">Toggle Panel</button>
<button id="toggleAuxiliary">Toggle Secondary Panel</button>
Expand Down
3 changes: 2 additions & 1 deletion demo/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -129,6 +129,7 @@ await initializeMonacoService({
StandaloneServices.get(ILogService).setLevel(LogLevel.Off)

export async function clearStorage (): Promise<void> {
await userDataProvider.reset()
await (await getService(IStorageService) as BrowserStorageService).clear()
}

Expand Down
4 changes: 3 additions & 1 deletion src/service-override/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
export async function createIndexedDBProviders (): Promise<IndexedDBFileSystemProvider> {
const userDataStore = 'vscode-userdata-store'
const logsStore = 'vscode-logs-store'
const handlesStore = 'vscode-filehandles-store'
Expand All @@ -554,6 +554,8 @@ export async function createIndexedDBProviders (): Promise<void> {

const userDataProvider = new IndexedDBFileSystemProvider(Schemas.vscodeUserData, indexedDB, userDataStore, true)
providers[Schemas.vscodeUserData] = userDataProvider

return userDataProvider
}

/**
Expand Down

0 comments on commit e66200e

Please sign in to comment.