MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / addClearCacheCommand

Function addClearCacheCommand

src/standalone/devTools/clearCache.ts:12–37  ·  view source on GitHub ↗
(context: IExtensionContext, isDevMode: boolean)

Source from the content-addressed store, hash-verified

10import { deleteTempDirs } from '../../platform/common/temp';
11
12export function addClearCacheCommand(context: IExtensionContext, isDevMode: boolean) {
13 if (!isDevMode) {
14 return;
15 }
16 commands.registerCommand('dataScience.ClearCache', async () => {
17 const promises: (Thenable<unknown> | Promise<unknown>)[] = [];
18 // eslint-disable-next-line no-restricted-syntax
19 for (const key of context.globalState.keys()) {
20 promises.push(context.globalState.update(key, undefined).then(noop, noop));
21 }
22 // eslint-disable-next-line no-restricted-syntax
23 for (const key of context.workspaceState.keys()) {
24 promises.push(context.workspaceState.update(key, undefined).then(noop, noop));
25 }
26 promises.push(commands.executeCommand(Commands.ClearSavedJupyterUris).then(noop, noop));
27 await Promise.all(promises).catch(noop);
28 // Delete the files after clearing the cache.
29 await Promise.all([
30 workspace.fs.delete(Uri.joinPath(context.globalStorageUri, 'lastExecutedRemoteCell.json')).then(noop, noop),
31 workspace.fs.delete(Uri.joinPath(context.globalStorageUri, 'remoteServersMRUList.json')).then(noop, noop),
32 workspace.fs.delete(Uri.joinPath(context.globalStorageUri, RemoteKernelSpecCacheFileName)).then(noop, noop),
33 deleteTempDirs(context).then(noop, noop)
34 ]);
35 logger.info('Cache cleared');
36 });
37}

Callers 1

registerTypesFunction · 0.90

Calls 10

deleteTempDirsFunction · 0.90
pushMethod · 0.65
updateMethod · 0.65
executeCommandMethod · 0.65
deleteMethod · 0.65
joinPathMethod · 0.65
infoMethod · 0.65
registerCommandMethod · 0.45
keysMethod · 0.45
allMethod · 0.45

Tested by

no test coverage detected