Commit 1ecfec5d authored by serya@chromium.org's avatar serya@chromium.org

Stop reflecting file operation results in wrong folders.

Previusly File Manager could insert just created folder in current dir event if it acually created in another. The same thing with renaming and deleting (but that ops are harder to reproduce).

BUG=138429
TEST=Create 2 identical folders on GDrive and downloads (it's important that other to swtich to contains files with the same names). Create new folder, rename a file, delete a bunch of files on GDrive and switch to Downloads.


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149628 0039d316-1c4b-4281-b951-d872f2087c98
parent 43088ef8
......@@ -494,6 +494,7 @@ DirectoryModel.prototype.replaceDirectoryContents_ = function(dirContents) {
*/
DirectoryModel.prototype.deleteEntries = function(entries, opt_callback) {
var downcount = entries.length + 1;
var currentDirPath = this.getCurrentDirPath();
var onComplete = opt_callback ? function() {
if (--downcount == 0)
......@@ -505,11 +506,13 @@ DirectoryModel.prototype.deleteEntries = function(entries, opt_callback) {
var entry = entries[i];
var onSuccess = function(removedEntry) {
var index = fileList.indexOf(removedEntry);
if (index >= 0)
fileList.splice(index, 1);
if (currentDirPath == this.getCurrentDirPath()) {
var index = fileList.indexOf(removedEntry);
if (index >= 0)
fileList.splice(index, 1);
}
onComplete();
}.bind(null, entry);
}.bind(this, entry);
util.removeFileOrDirectory(
entry,
......@@ -582,8 +585,14 @@ DirectoryModel.prototype.renameEntry = function(entry, newName,
errorCallback,
opt_successCallback) {
var self = this;
var currentDirPath = this.getCurrentDirPath();
function onSuccess(newEntry) {
self.currentDirContents_.prefetchMetadata([newEntry], function() {
// Do not change anything or call the callback if current
// directory changed.
if (currentDirPath != self.getCurrentDirPath())
return;
var index = self.findIndexByName_(entry.name);
if (index >= 0)
self.getFileList().splice(index, 1, newEntry);
......@@ -631,7 +640,14 @@ DirectoryModel.prototype.doesExist = function(entry, name, callback) {
*/
DirectoryModel.prototype.createDirectory = function(name, successCallback,
errorCallback) {
var currentDirPath = this.getCurrentDirPath();
var onSuccess = function(newEntry) {
// Do not change anything or call the callback if current
// directory changed.
if (currentDirPath != this.getCurrentDirPath())
return;
var existing = this.getFileList().slice().filter(
function(e) {return e.name == name;});
......
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