Skip to content

Commit

Permalink
fix(vscode): disabled permission denied launch error, strip quotes wh…
Browse files Browse the repository at this point in the history
…en checking path
  • Loading branch information
nedpals committed Mar 21, 2024
1 parent 4967d8b commit 8fa9011
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions vscode-bugbuddy/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { commands, env, window } from "vscode";
import { LanguageClient, LanguageClientOptions, ServerOptions } from "vscode-languageclient/node";
import { ConnectionStatus, extensionId, getWorkspaceConfig, openExplorerIn, outputChannel, setConnectionStatusTray } from "./utils";
import { existsSync, lstatSync } from "fs";
import { normalize } from "path";

export let currentConnectionStatus = ConnectionStatus.disconnected;
let serverProcess: ChildProcessWithoutNullStreams;
Expand Down Expand Up @@ -94,19 +95,28 @@ export function initializeServer() {

// check if path exists
console.log('Launching BugBuddy from', customPath);

if (!existsSync(customPath)) {
showServerLaunchError(BugBuddyServerLaunchErrorKind.PathNotFound, customPath);
return;

if (customPath.length !== 0) {
customPath = normalize(customPath)

let customPathStripped = customPath;
if (customPath.startsWith('"') && customPath.endsWith('"')) {
customPathStripped = customPath.slice(1, -1);
}

if (!existsSync(customPathStripped)) {
showServerLaunchError(BugBuddyServerLaunchErrorKind.PathNotFound, customPath);
return;
}
}

const customPathStat = lstatSync(customPath);
if (customPathStat.isDirectory()) {
showServerLaunchError(BugBuddyServerLaunchErrorKind.IsDirectory, customPath);
return;
} else if (!(customPathStat.mode & 0o100)) {
showServerLaunchError(BugBuddyServerLaunchErrorKind.PermissionDenied, customPath);
return;
// showServerLaunchError(BugBuddyServerLaunchErrorKind.PermissionDenied, customPath);
// return;
}

const newServerProcess = launchServer(customPath);
Expand Down

0 comments on commit 8fa9011

Please sign in to comment.