From 17806d932502adbf974ccd93a670e57b78be9a08 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 19 Aug 2023 01:00:24 -0700 Subject: fix: :bug: make sure server_version.txt exists --- extension/src/activation/environmentSetup.ts | 15 ++++++++++----- extension/src/commands.ts | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'extension/src') diff --git a/extension/src/activation/environmentSetup.ts b/extension/src/activation/environmentSetup.ts index 36fa245f..fe0c8c0b 100644 --- a/extension/src/activation/environmentSetup.ts +++ b/extension/src/activation/environmentSetup.ts @@ -180,11 +180,16 @@ export async function startContinuePythonServer(redownload: boolean = true) { let shouldDownload = true; if (fs.existsSync(destination) && redownload) { // Check if the server is the correct version - const serverVersion = fs.readFileSync(serverVersionPath(), "utf8"); - if (serverVersion === getExtensionVersion()) { - // The current version is already up and running, no need to continue - console.log("Continue server already downloaded"); - shouldDownload = false; + if (fs.existsSync(serverVersionPath())) { + const serverVersion = fs.readFileSync(serverVersionPath(), "utf8"); + if (serverVersion === getExtensionVersion()) { + // The current version is already up and running, no need to continue + console.log("Continue server already downloaded"); + shouldDownload = false; + } else { + console.log("Old version of the server downloaded"); + fs.unlinkSync(destination); + } } else { console.log("Old version of the server downloaded"); fs.unlinkSync(destination); diff --git a/extension/src/commands.ts b/extension/src/commands.ts index 4761826e..5a880690 100644 --- a/extension/src/commands.ts +++ b/extension/src/commands.ts @@ -1,6 +1,7 @@ import * as vscode from "vscode"; import * as path from "path"; import * as os from "os"; +import * as fs from "fs"; import { acceptDiffCommand, rejectDiffCommand } from "./diffs"; import { debugPanelWebview } from "./debugPanel"; @@ -60,6 +61,12 @@ const commandsMap: { [command: string]: (...args: any) => any } = { "continue.viewLogs": async () => { // Open ~/.continue/continue.log const logFile = path.join(os.homedir(), ".continue", "continue.log"); + // Make sure the file/directory exist + if (!fs.existsSync(logFile)) { + fs.mkdirSync(path.dirname(logFile), { recursive: true }); + fs.writeFileSync(logFile, ""); + } + const uri = vscode.Uri.file(logFile); await vscode.window.showTextDocument(uri); }, -- cgit v1.2.3-70-g09d2