提交 834d72dc 编写于 作者: B Benjamin Pasero

files2 - try to fix tests

上级 cd7a1069
...@@ -18,6 +18,8 @@ export function watchFolder(path: string, onChange: (type: 'added' | 'changed' | ...@@ -18,6 +18,8 @@ export function watchFolder(path: string, onChange: (type: 'added' | 'changed' |
return doWatchNonRecursive({ path, isDirectory: true }, onChange, onError); return doWatchNonRecursive({ path, isDirectory: true }, onChange, onError);
} }
export const CHANGE_BUFFER_DELAY = 100;
function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onChange: (type: 'added' | 'changed' | 'deleted', path: string) => void, onError: (error: string) => void): IDisposable { function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onChange: (type: 'added' | 'changed' | 'deleted', path: string) => void, onError: (error: string) => void): IDisposable {
const mapPathToStatDisposable = new Map<string, IDisposable>(); const mapPathToStatDisposable = new Map<string, IDisposable>();
...@@ -101,7 +103,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha ...@@ -101,7 +103,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha
else { else {
onChange('deleted', changedFilePath); onChange('deleted', changedFilePath);
} }
}, 300); }, CHANGE_BUFFER_DELAY);
// Very important to dispose the watcher which now points to a stale inode // Very important to dispose the watcher which now points to a stale inode
// and wire in a new disposable that tracks our timeout that is installed // and wire in a new disposable that tracks our timeout that is installed
...@@ -151,7 +153,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha ...@@ -151,7 +153,7 @@ function doWatchNonRecursive(file: { path: string, isDirectory: boolean }, onCha
} }
onChange(type, changedFilePath); onChange(type, changedFilePath);
}, 100); }, CHANGE_BUFFER_DELAY);
mapPathToStatDisposable.set(changedFilePath, toDisposable(() => clearTimeout(timeoutHandle))); mapPathToStatDisposable.set(changedFilePath, toDisposable(() => clearTimeout(timeoutHandle)));
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import { IDiskFileChange, normalizeFileChanges } from 'vs/workbench/services/files2/node/watcher/normalizer'; import { IDiskFileChange, normalizeFileChanges } from 'vs/workbench/services/files2/node/watcher/normalizer';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { statLink, readlink } from 'vs/base/node/pfs'; import { statLink, readlink } from 'vs/base/node/pfs';
import { watchFolder, watchFile } from 'vs/base/node/watcher'; import { watchFolder, watchFile, CHANGE_BUFFER_DELAY } from 'vs/base/node/watcher';
import { FileChangeType } from 'vs/platform/files/common/files'; import { FileChangeType } from 'vs/platform/files/common/files';
import { ThrottledDelayer } from 'vs/base/common/async'; import { ThrottledDelayer } from 'vs/base/common/async';
import { join, basename } from 'vs/base/common/path'; import { join, basename } from 'vs/base/common/path';
...@@ -14,7 +14,7 @@ import { join, basename } from 'vs/base/common/path'; ...@@ -14,7 +14,7 @@ import { join, basename } from 'vs/base/common/path';
export class FileWatcher extends Disposable { export class FileWatcher extends Disposable {
private isDisposed: boolean; private isDisposed: boolean;
private fileChangesDelayer: ThrottledDelayer<void> = this._register(new ThrottledDelayer<void>(50)); private fileChangesDelayer: ThrottledDelayer<void> = this._register(new ThrottledDelayer<void>(CHANGE_BUFFER_DELAY * 2 /* sync on delay from underlying library */));
private fileChangesBuffer: IDiskFileChange[] = []; private fileChangesBuffer: IDiskFileChange[] = [];
constructor( constructor(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册