Commit 7f9c765e authored by mtomasz@chromium.org's avatar mtomasz@chromium.org

Fix problems when renaming and entering a directory fast in Files.app.

Renaming on Drive takes significant amount of time. Renaming and immediately entering a directory, caused later staying in a directory which no more exists. This patch resolves this issue by changing to the new directory from the old one, once the renaming operation is finished.

TEST=Create a directory, enter some different name, double hit ENTER. Try to create a directory again. Should not fail.
BUG=227456

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@203961 0039d316-1c4b-4281-b951-d872f2087c98
parent 14ba6e25
......@@ -686,8 +686,13 @@ DirectoryModel.prototype.renameEntry = function(entry, newName,
var currentDirPath = this.getCurrentDirPath();
var onSuccess = function(newEntry) {
this.currentDirContents_.prefetchMetadata([newEntry], function() {
// Do not change anything or call the callback if current
// directory changed.
// If the current directory is the old entry, then quietly change to the
// new one.
if (entry.fullPath == this.getCurrentDirPath())
this.changeDirectory(newEntry.fullPath);
// Update selection and call the success callback if still in the same
// directory as while started renaming.
if (currentDirPath != this.getCurrentDirPath())
return;
......
......@@ -2632,7 +2632,7 @@ DialogType.isModal = function(type) {
var onError = function(err) {
this.alert.show(strf('ERROR_RENAMING', entry.name,
util.getFileErrorString(err.code)));
};
}.bind(this);
this.directoryModel_.renameEntry(entry, newName, onError.bind(this));
} else {
nameNode.textContent = entry.name;
......
......@@ -373,10 +373,25 @@ DirectoryItem.prototype.decorate = function(
* a complex layout. This call is not necessary, so we are ignoring it.
*
* @param {boolean} unused Unused.
* @override
*/
DirectoryItem.prototype.scrollIntoViewIfNeeded = function(unused) {
};
/**
* Removes the child node, but without selecting the parent item, to avoid
* unintended changing of directories. Removing is done externally, and other
* code will navigate to another directory.
*
* @param {!cr.ui.TreeItem} child The tree item child to remove.
* @override
*/
DirectoryItem.prototype.remove = function(child) {
this.lastElementChild.removeChild(child);
if (this.items.length == 0)
this.hasChildren = false;
};
/**
* Invoked when the item is being expanded.
* @param {!UIEvent} e Event.
......
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