(context: IExtensionContext, isDevMode: boolean)
| 10 | import { deleteTempDirs } from '../../platform/common/temp'; |
| 11 | |
| 12 | export 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 | } |
no test coverage detected