Index: chrome/browser/resources/file_manager/js/directory_model.js |
diff --git a/chrome/browser/resources/file_manager/js/directory_model.js b/chrome/browser/resources/file_manager/js/directory_model.js |
index 1b30c3f409fd5812e47a54a99ef183bdf0274fa5..2f4c8495f5174bfcf0881c927431bdfc56f65106 100644 |
--- a/chrome/browser/resources/file_manager/js/directory_model.js |
+++ b/chrome/browser/resources/file_manager/js/directory_model.js |
@@ -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(); |
Vladislav Kaznacheev
2012/08/02 12:45:39
Is it safe to call the callback if the directory h
SeRya
2012/08/02 12:56:20
Sure. And it's called. Only fileList update is omi
|
- }.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(); |
Vladislav Kaznacheev
2012/08/02 12:45:39
I see the pattern here. How about creating a wrapp
SeRya
2012/08/02 12:56:20
In my oppinion cost of this level of abstraction d
|
+ |
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;}); |