提交 94aaf389 编写于 作者: B Benjamin Pasero

debt - dispose one CancellationTokenSource

上级 e3ce0299
......@@ -278,14 +278,14 @@ export class FileService implements IFileService {
value: void 0
};
const contentResolverToken = new CancellationTokenSource();
const contentResolverTokenSource = new CancellationTokenSource();
const onStatError = (error: Error) => {
// error: stop reading the file the stat and content resolve call
// usually race, mostly likely the stat call will win and cancel
// the content call
contentResolverToken.cancel();
contentResolverTokenSource.cancel();
// forward error
return TPromise.wrapError(error);
......@@ -353,17 +353,21 @@ export class FileService implements IFileService {
// etag from the stat before we actually read the file again.
if (options && options.etag) {
completePromise = statsPromise.then(() => {
return this.fillInContents(result, resource, options, contentResolverToken.token); // Waterfall -> only now resolve the contents
return this.fillInContents(result, resource, options, contentResolverTokenSource.token); // Waterfall -> only now resolve the contents
});
}
// a fresh load without a previous etag which means we can resolve the file stat
// and the content at the same time, avoiding the waterfall.
else {
completePromise = Promise.all([statsPromise, this.fillInContents(result, resource, options, contentResolverToken.token)]);
completePromise = Promise.all([statsPromise, this.fillInContents(result, resource, options, contentResolverTokenSource.token)]);
}
return TPromise.wrap(completePromise).then(() => result);
return TPromise.wrap(completePromise).then(() => {
contentResolverTokenSource.dispose();
return result;
});
}
private fillInContents(content: IStreamContent, resource: uri, options: IResolveContentOptions, token: CancellationToken): Thenable<any> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册