Skip to content

Commit 6375232

Browse files
Revert changes on filebrowser watches
Reverted because it could have caused freezes and another fix for the problem was found here : HaxeFoundation/haxe@1568248 reverts dd17aa7 and cfcd4e1.
1 parent b1637d9 commit 6375232

1 file changed

Lines changed: 9 additions & 22 deletions

File tree

hide_js/hide/tools/FileManager.hx

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class FileEntry {
5252
public var vcsStatus: VCSStatus = None;
5353
public var ignored: Bool = false;
5454

55-
var nativeWatcher = null;
55+
var registeredWatcher : hide.tools.FileWatcher.FileWatchEvent = null;
5656

5757
public function new(name: String, parent: FileEntry, kind: FileKind) {
5858
this.name = name;
@@ -78,8 +78,10 @@ class FileEntry {
7878
}
7979
disposed = true;
8080
children = null;
81-
nativeWatcher.close();
82-
nativeWatcher = null;
81+
if (registeredWatcher != null) {
82+
hide.Ide.inst.fileWatcher.unregister(this.getPath(), registeredWatcher.fun);
83+
registeredWatcher = null;
84+
}
8385
FileManager.inst.fileIndex.remove(this.getRelPath());
8486
}
8587

@@ -130,24 +132,11 @@ class FileEntry {
130132
}
131133

132134
function watch() {
133-
if (kind == Dir) {
134-
nativeWatcher = js.node.Fs.watch(getPath(), onWatcherEvent);
135-
}
136-
}
137-
138-
function onWatcherEvent(type, path) {
139-
if (path == ".tmp")
140-
return;
141-
142-
var base = getRelPath();
143-
var filePath : String = base.length > 0 ? base + "/" + path : path;
135+
if (registeredWatcher != null)
136+
throw "already watching";
144137

145-
var child = FileManager.inst.getFileEntry(filePath);
146-
if (child != null) {
147-
FileManager.inst.fileChangeInternal(child);
148-
} else {
149-
FileManager.inst.fileChangeInternal(this);
150-
}
138+
var rel = this.getRelPath();
139+
registeredWatcher = hide.Ide.inst.fileWatcher.register(rel, FileManager.inst.fileChangeInternal.bind(this), true);
151140
}
152141

153142
public inline function getRelPath() {
@@ -220,8 +209,6 @@ class FileManager {
220209

221210
var fileEntryRefreshDelay : Delayer<FileEntry>;
222211

223-
var watcher : js.node.fs.FSWatcher;
224-
225212
var retries = 0;
226213
static final maxRetries = 5;
227214

0 commit comments

Comments
 (0)