Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore widget files storage dir to extension dir #16012

Merged
merged 4 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { BaseIPyWidgetScriptManager } from './baseIPyWidgetScriptManager';
import { IIPyWidgetScriptManager, INbExtensionsPathProvider } from '../types';
import { JupyterPaths } from '../../../../kernels/raw/finder/jupyterPaths.node';
import { logger } from '../../../../platform/logging';
import { getExtensionTempDir } from '../../../../platform/common/temp';

type KernelConnectionId = string;
/**
Expand Down Expand Up @@ -75,7 +74,7 @@ export class LocalIPyWidgetScriptManager extends BaseIPyWidgetScriptManager impl
return;
}
const kernelHash = await getTelemetrySafeHashedString(this.kernel.kernelConnectionMetadata.id);
const baseUrl = Uri.joinPath(getExtensionTempDir(this.context), 'scripts', kernelHash, 'jupyter');
const baseUrl = Uri.joinPath(this.context.extensionUri, 'temp', 'scripts', kernelHash, 'jupyter');

const targetNbExtensions = Uri.joinPath(baseUrl, 'nbextensions');
const [jupyterDataDirectories] = await Promise.all([
Expand Down
6 changes: 3 additions & 3 deletions src/platform/webviews/webviewPanelProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { Uri, ViewColumn, WebviewOptions, WebviewPanel as vscodeWebviewPanel, wi
import { IWebviewPanel, IWebviewPanelOptions, IWebviewPanelProvider } from '../common/application/types';
import { IFileSystem } from '../common/platform/types';
import { IDisposableRegistry, IExtensionContext } from '../common/types';
import * as path from '../vscode-path/path';
import { Webview } from './webview';
import { getExtensionTempDir } from '../common/temp';

class WebviewPanel extends Webview implements IWebviewPanel {
private get panel(): vscodeWebviewPanel | undefined {
Expand Down Expand Up @@ -120,9 +120,9 @@ export class WebviewPanelProvider implements IWebviewPanelProvider {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
public async create(options: IWebviewPanelOptions): Promise<IWebviewPanel> {
// Allow loading resources from the `<extension global storage folder>/<version>` folder when in webiviews.
// Allow loading resources from the `<extension folder>/temp` folder when in webiviews.
// Used by widgets to place files that are not otherwise accessible.
const additionalRootPaths = [getExtensionTempDir(this.context)];
const additionalRootPaths = [Uri.file(path.join(this.context.extensionPath, 'temp'))];
if (Array.isArray(options.additionalPaths)) {
additionalRootPaths.push(...options.additionalPaths);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import { createActiveInterpreterController } from '../notebook/helpers';
import { IInterpreterService } from '../../../platform/interpreter/contracts';
import { IControllerRegistration } from '../../../notebooks/controllers/types';
import { HttpClient } from '../../../platform/common/net/httpClient';
import { getExtensionTempDir } from '../../../platform/common/temp';

suite('IPyWidget Script Manager @widgets', function () {
this.timeout(120_000);
Expand Down Expand Up @@ -121,7 +120,8 @@ suite('IPyWidget Script Manager @widgets', function () {
assert.fail('We should have started a Python kernel');
} else {
const expectedDir = Uri.joinPath(
getExtensionTempDir(context),
context.extensionUri,
'temp',
'scripts',
await getTelemetrySafeHashedString(kernel.kernelConnectionMetadata.id),
'jupyter'
Expand All @@ -140,7 +140,8 @@ suite('IPyWidget Script Manager @widgets', function () {
return this.skip();
}
const expectedDir = Uri.joinPath(
getExtensionTempDir(context),
context.extensionUri,
'temp',
'scripts',
await getTelemetrySafeHashedString(kernel.kernelConnectionMetadata.id),
'jupyter'
Expand All @@ -156,7 +157,7 @@ suite('IPyWidget Script Manager @widgets', function () {
// await del([nbExtensionsFolder]);
const fsNode = api.serviceContainer.get<IFileSystemNode>(IFileSystemNode);
// eslint-disable-next-line local-rules/dont-use-fspath
await fsNode.delete(Uri.file(nbExtensionsFolder.fsPath));
await fsNode.delete(nbExtensionsFolder);
assert.isFalse(await fs.exists(nbExtensionsFolder), `Directory '${nbExtensionsFolder}'does not exist`);

await kernel.restart();
Expand Down
Loading