Commit 4f69a017 authored by rbyers@chromium.org's avatar rbyers@chromium.org

Fix file manager to better handle missing roots and scan failure

On device, FileManager should always see at least one root (Downloads), but when doing development on Linux some engineers may not have any local paths setup.  This CL improves error handling in this case.

Also I realized that our directory scan logic is setup to periodically retry (silently dropping the completion callback on the floor) rather than have any hard failure notification.  I don't know when this could happen in practice, but if it did it could break my redraw reduction optimization. Similarly, if a scan is aborted (eg. because the active root is quickly changed and a new scan is started) we may not get the callback.  I don't see any trivial low-risk solutions to this problem, so given where we are in the schedule I decided it was better to remove this optimization for now rather than risk any further regression.

BUG=chromium-os:27241
TEST=

Review URL: https://chromiumcodereview.appspot.com/9701063

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126968 0039d316-1c4b-4281-b951-d872f2087c98
parent 723538f8
......@@ -330,7 +330,14 @@ DirectoryModel.prototype = {
/**
* Cancels waiting and scheduled rescans and starts new scan.
*
* @param {Function} callback Called when scan completed.
* If the scan completes successfully on the first attempt, the callback will
* be invoked and a 'scan-completed' event will be dispatched. If the scan
* fails for any reason, we'll periodically retry until it succeeds (and then
* send a 'rescan-complete' event) or is cancelled or replaced by another
* scan.
*
* @param {Function} callback Called if scan completes on the first attempt.
* Note that this will NOT be called if the scan fails but later succeeds.
*/
scan_: function(callback) {
if (this.rescanTimeout_) {
......@@ -497,9 +504,9 @@ DirectoryModel.prototype = {
* changed.
*
* @param {DirectoryEntry} dirEntry The absolute path to the new directory.
* @param {function} action Action executed when the directory loaded.
* By default selects the first item
* (unless it's a save dialog).
* @param {function} action Action executed if the directory loads
* successfully. By default selects the first item (unless it's a save
* dialog).
* @param {boolean} initial True if it comes from setupPath and
* false if caused by an user action.
*/
......@@ -528,7 +535,9 @@ DirectoryModel.prototype = {
*
* @param {string} path The root path to use
* @param {Function=} opt_loadedCallback Invoked when the entire directory
* has been loaded and any default file selected.
* has been loaded and any default file selected. If there are any
* errors loading the directory this will not get called (even if the
* directory loads OK on retry later).
* @param {Function=} opt_pathResolveCallback Invoked as soon as the path has
* been resolved, and called with the base and leaf portions of the path
* name, and a flag indicating if the entry exists.
......@@ -597,7 +606,7 @@ DirectoryModel.prototype = {
} else {
// Well, we can't find the downloads dir. Let's just show something,
// or we will get an infinite recursion.
this.changeDirectory('/', opt_loadedCallback, true);
this.changeDirectoryEntry_(this.root_, opt_loadedCallback, true);
}
}.bind(this);
......
......@@ -1473,13 +1473,6 @@ FileManager.prototype = {
* window has neither.
*/
FileManager.prototype.setupCurrentDirectory_ = function() {
// Avoid a bunch of intermediate list redraws while the data model is
// cleared and updated. Note that it may (or may not) be desirable to draw
// partial results as we get them, but today the DirectoryReader API
// generally returns all entries in one chunk so even without this batching
// we wouldn't have incremental updates.
this.table_.startBatchUpdates();
var onLoaded = this.table_.endBatchUpdates.bind(this.table_);
if (location.hash) {
// Location hash has the highest priority.
......@@ -1513,7 +1506,6 @@ FileManager.prototype = {
// until the selection is done.
var self = this;
function onLoadedActivateLeaf() {
onLoaded();
if (foundLeaf) {
self.dispatchDefaultTask_();
setTimeout(removeShade, 1000);
......@@ -1524,14 +1516,14 @@ FileManager.prototype = {
return;
}
this.directoryModel_.setupPath(path, onLoaded);
this.directoryModel_.setupPath(path);
return;
}
if (this.params_.defaultPath) {
var path = this.params_.defaultPath;
if (this.dialogType_ == FileManager.DialogType.SELECT_SAVEAS_FILE) {
this.directoryModel_.setupPath(path, onLoaded,
this.directoryModel_.setupPath(path, undefined,
function(basePath, leafName) {
this.filenameInput_.value = leafName;
this.selectDefaultPathInFilenameInput_();
......@@ -1539,11 +1531,11 @@ FileManager.prototype = {
return;
}
this.directoryModel_.setupPath(path, onLoaded);
this.directoryModel_.setupPath(path);
return;
}
this.directoryModel_.setupDefaultPath(onLoaded);
this.directoryModel_.setupDefaultPath();
};
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment