Skip to content
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

Avoid using chokidar (Fix #762) #763

Merged
merged 3 commits into from
Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion install_local.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
npm install
vsce package
code --install-extension code-settings-sync-2.9.0.vsix
code --install-extension code-settings-sync-3.2.4.vsix
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@
"dependencies": {
"@octokit/rest": "^16.2.0",
"adm-zip": "^0.4.13",
"chokidar": "^2.0.4",
"fs-extra": "^7.0.1",
"https-proxy-agent": "^2.2.1",
"lockfile": "^1.0.4",
Expand Down
23 changes: 11 additions & 12 deletions src/commons.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"use strict";
import * as chokidar from "chokidar";
import * as fs from "fs-extra";
import * as vscode from "vscode";
import { Environment } from "./environmentPath";
Expand Down Expand Up @@ -97,14 +96,12 @@ export default class Commons {
}

let uploadStopped: boolean = true;
Commons.extensionWatcher = chokidar.watch(this.en.ExtensionFolder, {
depth: 0,
ignoreInitial: true
});
Commons.configWatcher = chokidar.watch(this.en.PATH + "/User/", {
depth: 2,
Copy link
Owner

Choose a reason for hiding this comment

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

How are you handling the depth as 2 in File System Watcher

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean the watcher should not watch under directories in workspaceStorage.
OK, I'll try handling it! Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@shanalikhan
Fixed by 758baf7
But it's not beautiful way... umm...

ignoreInitial: true
Copy link
Owner

Choose a reason for hiding this comment

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

It would be great if you can write details how are you handling these situations on FileSystemWatcher

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The watcher doesn't watch the add event now, so I think it's not problem to ignore this option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now, I checked this behavior.
FileSystemWatcher and chokidar with ignoreInitial: true are same. 😄

Add the following code for check, and Added: logs are not appeared when the window reloads.

    Commons.configWatcher.onDidCreate(async (uri: vscode.Uri) => {
      const path: string = uri.path;
      console.log("Added: " + path);
    });

I also checked the case of ignoreInitial: false. nekonenene@5941286

sc 619

});
Commons.extensionWatcher = vscode.workspace.createFileSystemWatcher(
this.en.ExtensionFolder + "*"
);
Commons.configWatcher = vscode.workspace.createFileSystemWatcher(
this.en.PATH + "/User/" + "{*,*/*,*/*/*}" // depth: 2
);

// TODO : Uncomment the following lines when code allows feature to update Issue in github code repo - #14444

Expand Down Expand Up @@ -137,7 +134,9 @@ export default class Commons {
// }
// });

Commons.configWatcher.on("change", async (path: string) => {
Commons.configWatcher.onDidChange(async (uri: vscode.Uri) => {
const path: string = uri.path;

// check sync is locking
if (await lockfile.Check(this.en.FILE_SYNC_LOCK)) {
uploadStopped = false;
Expand Down Expand Up @@ -234,10 +233,10 @@ export default class Commons {

public CloseWatch(): void {
if (Commons.configWatcher != null) {
Commons.configWatcher.close();
Commons.configWatcher.dispose();
}
if (Commons.extensionWatcher != null) {
Commons.extensionWatcher.close();
Commons.extensionWatcher.dispose();
}
}

Expand Down