Skip to content

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

Merged
merged 3 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
change: global state name
  • Loading branch information
yihong0618 committed Jul 23, 2020
commit e326d8ca337e115f6c0181dfb53b1b9c2092fef8
6 changes: 3 additions & 3 deletions src/leetCodeExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, globalStateLeetcodeHasInited, IProblem, supportedPlugins } from "./shared";
import { Endpoint, IProblem, leetcodeHasInited, supportedPlugins } from "./shared";
import { executeCommand, executeCommandWithProgress } from "./utils/cpUtils";
import { DialogOptions, openUrl } from "./utils/uiUtils";
import * as wsl from "./utils/wslUtils";
Expand Down Expand Up @@ -37,7 +37,7 @@ class LeetCodeExecutor implements Disposable {
}

public async meetRequirements(context: ExtensionContext): Promise<boolean> {
const hasInited: boolean | undefined = context.globalState.get(globalStateLeetcodeHasInited);
const hasInited: boolean | undefined = context.globalState.get(leetcodeHasInited);
if (!hasInited) {
await this.removeOldCache();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdneo
delete cache only delete the user session but not the plugin.js cache, still have that issue. So I think we can not use it..
image

Copy link
Member

@jdneo jdneo Jul 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need to change the implementation of the command delete cache. Considering that the current implementation does not clean entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 delete cache also have one problem beacuse user may have two account one leetcode one leetcode-cn, if we change that. both will clean, but user may only want to clean the current cache.

Copy link
Member

Choose a reason for hiding this comment

The 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 Session and All. Anyway it's not a high priority

}
Expand Down Expand Up @@ -72,7 +72,7 @@ class LeetCodeExecutor implements Disposable {
}
}
// Set the global state HasInited true to skip delete old cache after init
context.globalState.update(globalStateLeetcodeHasInited, true);
context.globalState.update(leetcodeHasInited, true);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ export enum DescriptionConfiguration {
None = "None",
}

export const globalStateLeetcodeHasInited: string = "leetcode.isUserFresh";
export const leetcodeHasInited: string = "leetcode.hasInited";