diff --git a/src/filesystem/FileSystem.js b/src/filesystem/FileSystem.js index df019859b89..32b4b07e48e 100644 --- a/src/filesystem/FileSystem.js +++ b/src/filesystem/FileSystem.js @@ -823,9 +823,7 @@ define(function (require, exports, module) { * mechanism. */ FileSystem.prototype.clearAllCaches = function () { - this._index.visitAll(function (entry) { - entry._clearCachedData(true); - }); + this._handleExternalChange(null); }; /** diff --git a/src/project/ProjectManager.js b/src/project/ProjectManager.js index 7f836316a95..c7d856cd65e 100644 --- a/src/project/ProjectManager.js +++ b/src/project/ProjectManager.js @@ -920,21 +920,6 @@ define(function (require, exports, module) { return result.promise(); } - /** - * @private - * @type {?$.Promise} Resolves when the currently running instance of - * _refreshFileTreeInternal completes, or null if there is no currently - * running instance. - */ - var _refreshFileTreePromise = null; - - /** - * @type {boolean} If refreshFileTree is called before _refreshFileTreePromise - * has resolved then _refreshPending is set, which indicates that - * refreshFileTree should be called again once the promise resolves. - */ - var _refreshPending = false; - /** * @const * @private @@ -944,38 +929,16 @@ define(function (require, exports, module) { /** * Refresh the project's file tree, maintaining the current selection. - * - * @return {$.Promise} A promise object that will be resolved when the - * project tree is reloaded, or rejected if the project path - * fails to reload. If the previous selected entry is not found, - * the promise is still resolved. + * + * Note that the original implementation of this returned a promise to be resolved when the refresh is complete. + * That use is deprecated and `refreshFileTree` is now a "fire and forget" kind of function. */ - function refreshFileTree() { - if (!_refreshFileTreePromise) { - var internalRefreshPromise = model.refresh(), - deferred = new $.Deferred(); - - _refreshFileTreePromise = deferred.promise(); - - _refreshFileTreePromise.always(function () { - _refreshFileTreePromise = null; - - if (_refreshPending) { - _refreshPending = false; - refreshFileTree(); - } - }); - - // Wait at least one second before resolving the promise - window.setTimeout(function () { - internalRefreshPromise.then(deferred.resolve, deferred.reject); - }, _refreshDelay); - } else { - _refreshPending = true; - } - - return _refreshFileTreePromise; - } + var refreshFileTree = function refreshFileTree() { + FileSystem.clearAllCaches(); + return new $.Deferred().resolve().promise(); + }; + + refreshFileTree = _.debounce(refreshFileTree, _refreshDelay); /** * Expands tree nodes to show the given file or folder and selects it. Silently no-ops if the diff --git a/src/project/ProjectModel.js b/src/project/ProjectModel.js index 951fd7218b0..7c0a7f551e2 100644 --- a/src/project/ProjectModel.js +++ b/src/project/ProjectModel.js @@ -1076,16 +1076,6 @@ define(function (require, exports, module) { } }; - /** - * @private - * - * Clear all caches associated with the project. - */ - ProjectModel.prototype._clearAllCaches = function () { - this._resetCache(); - FileSystem.clearAllCaches(); - }; - /** * Clears caches and refreshes the contents of the tree. * @@ -1099,7 +1089,6 @@ define(function (require, exports, module) { viewModel = this._viewModel, deferred = new $.Deferred(); - this._clearAllCaches(); this.setProjectRoot(projectRoot).then(function () { self.reopenNodes(openNodes).then(function () { if (selections.selected) { diff --git a/test/spec/ProjectModel-test.js b/test/spec/ProjectModel-test.js index da8d189d74a..20dcd6da18f 100644 --- a/test/spec/ProjectModel-test.js +++ b/test/spec/ProjectModel-test.js @@ -1080,7 +1080,6 @@ define(function (require, exports, module) { it("should refresh the whole tree", function () { var oldTree; - spyOn(model, "_clearAllCaches"); waitsForDone(model.reopenNodes(data.nodesByDepth)); runs(function () { model.setSelected("/foo/subdir1/subsubdir/interior.txt"); @@ -1103,7 +1102,6 @@ define(function (require, exports, module) { expect(vm._treeData.getIn(["subdir1", "children", "subsubdir", "children", "newInterior.txt"])).toBeDefined(); expect(vm._treeData.getIn(["subdir1", "children", "subsubdir", "children", "interior.txt"])).toBeUndefined(); expect(vm._treeData.getIn(["subdir3", "children", "higher.txt", "context"])).toBe(true); - expect(model._clearAllCaches).toHaveBeenCalled(); }); }); });