]> git.lizzy.rs Git - rust.git/commitdiff
internal: use vscode.FileSystem API in main.ts
authorwxb1ank <wxblank@gmail.com>
Sun, 23 May 2021 20:33:32 +0000 (16:33 -0400)
committerwxb1ank <wxblank@gmail.com>
Wed, 2 Jun 2021 16:07:13 +0000 (12:07 -0400)
editors/code/src/config.ts
editors/code/src/main.ts

index d3d6e631a029068592871bdc41398d512a73b14b..7200a26f72aeaeaf525f35c07dbb4114d74faa9b 100644 (file)
@@ -31,10 +31,10 @@ export class Config {
         enableProposedApi: boolean | undefined;
     } = vscode.extensions.getExtension(this.extensionId)!.packageJSON;
 
-    readonly globalStoragePath: string;
+    readonly globalStorageUri: vscode.Uri;
 
     constructor(ctx: vscode.ExtensionContext) {
-        this.globalStoragePath = ctx.globalStorageUri.fsPath;
+        this.globalStorageUri = ctx.globalStorageUri;
         vscode.workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, ctx.subscriptions);
         this.refreshLogging();
     }
index 74ee28d24578ea34dd5d62d67c0f73b6722c70dd..fb9d38a14ddd918a08cfc78429be8fc353413438 100644 (file)
@@ -160,7 +160,7 @@ export async function deactivate() {
 }
 
 async function bootstrap(config: Config, state: PersistentState): Promise<string> {
-    await fs.mkdir(config.globalStoragePath, { recursive: true });
+    await vscode.workspace.fs.createDirectory(config.globalStorageUri);
 
     if (!config.currentExtensionIsNightly) {
         await state.updateNightlyReleaseId(undefined);
@@ -222,7 +222,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
     const artifact = latestNightlyRelease.assets.find(artifact => artifact.name === "rust-analyzer.vsix");
     assert(!!artifact, `Bad release: ${JSON.stringify(latestNightlyRelease)}`);
 
-    const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix");
+    const dest = path.join(config.globalStorageUri.path, "rust-analyzer.vsix");
 
     await downloadWithRetryDialog(state, async () => {
         await download({
@@ -334,7 +334,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
         platform = "x86_64-unknown-linux-musl";
     }
     const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : "";
-    const dest = path.join(config.globalStoragePath, `rust-analyzer-${platform}${ext}`);
+    const dest = path.join(config.globalStorageUri.path, `rust-analyzer-${platform}${ext}`);
     const exists = await fs.stat(dest).then(() => true, () => false);
     if (!exists) {
         await state.updateServerVersion(undefined);