Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(528)

Unified Diff: chrome/browser/resources/file_manager/js/directory_model.js

Issue 10831127: Stop reflecting file operation results in wrong folders. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698