-
Notifications
You must be signed in to change notification settings - Fork 677
fix: #593 by adding global flag to remove cache #602
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import * as path from "path"; | |
import * as requireFromString from "require-from-string"; | ||
import { ExtensionContext } from "vscode"; | ||
import { ConfigurationChangeEvent, Disposable, MessageItem, window, workspace, WorkspaceConfiguration } from "vscode"; | ||
import { Endpoint, globalStateLeetcodeIsUserFresh, IProblem, supportedPlugins } from "./shared"; | ||
import { Endpoint, globalStateLeetcodeHasInited, IProblem, supportedPlugins } from "./shared"; | ||
import { executeCommand, executeCommandWithProgress } from "./utils/cpUtils"; | ||
import { DialogOptions, openUrl } from "./utils/uiUtils"; | ||
import * as wsl from "./utils/wslUtils"; | ||
|
@@ -37,8 +37,8 @@ class LeetCodeExecutor implements Disposable { | |
} | ||
|
||
public async meetRequirements(context: ExtensionContext): Promise<boolean> { | ||
const isUserFresh: boolean | undefined = context.globalState.get(globalStateLeetcodeIsUserFresh); | ||
if (isUserFresh !== false) { | ||
const hasInited: boolean | undefined = context.globalState.get(globalStateLeetcodeHasInited); | ||
if (!hasInited) { | ||
await this.removeOldCache(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reuse the command we have? https://github.com/LeetCode-OpenSource/vscode-leetcode/blob/master/src/extension.ts#L51 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems a little different.The command way use leetcode-cli way not delete the whole dir, let me check if it works fine too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we need to change the implementation of the command There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, current one only clean the user info(include session), but we change the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. So let's keep the implementation. Maybe later we can provide two option in this command. Something like |
||
} | ||
if (this.nodeExecutable !== "node") { | ||
|
@@ -66,12 +66,13 @@ class LeetCodeExecutor implements Disposable { | |
for (const plugin of supportedPlugins) { | ||
try { // Check plugin | ||
await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "plugin", "-e", plugin]); | ||
} catch (error) { // Download plugin and activate | ||
} catch (error) { // Remove old cache that may cause the error download plugin and activate | ||
await this.removeOldCache(); | ||
await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "plugin", "-i", plugin]); | ||
} | ||
} | ||
context.globalState.update(globalStateLeetcodeIsUserFresh, false); | ||
// Set the global state HasInited true to skip delete old cache after init | ||
context.globalState.update(globalStateLeetcodeHasInited, true); | ||
return true; | ||
} | ||
|
||
|
@@ -84,7 +85,7 @@ class LeetCodeExecutor implements Disposable { | |
} | ||
|
||
public async signOut(): Promise<string> { | ||
return await await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "user", "-L"]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems that its an old typo so I changed it too, am I right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes |
||
return await this.executeCommandEx(this.nodeExecutable, [await this.getLeetCodeBinaryPath(), "user", "-L"]); | ||
} | ||
|
||
public async listProblems(showLocked: boolean): Promise<string> { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,4 +115,4 @@ export enum DescriptionConfiguration { | |
None = "None", | ||
} | ||
|
||
export const globalStateLeetcodeIsUserFresh: string = "leetcode.isUserFresh"; | ||
export const globalStateLeetcodeHasInited: string = "leetcode.isUserFresh"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also change the value. No need to have the prefix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it~! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |