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

Unified Diff: ui/file_manager/file_manager/foreground/js/directory_contents.js

Issue 676293002: Avoid inserting duplicated entries after creating a directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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: ui/file_manager/file_manager/foreground/js/directory_contents.js
diff --git a/ui/file_manager/file_manager/foreground/js/directory_contents.js b/ui/file_manager/file_manager/foreground/js/directory_contents.js
index 5aa0678138ee08b0b6f68232d8bb6da702c7da7e..49b0d2c55c604bf2236434cdc44a80f5ef3bf873 100644
--- a/ui/file_manager/file_manager/foreground/js/directory_contents.js
+++ b/ui/file_manager/file_manager/foreground/js/directory_contents.js
@@ -824,6 +824,14 @@ DirectoryContents.prototype.onNewEntries_ = function(refresh, entries) {
this.processNewEntriesQueue_.run(function(callbackOuter) {
var finish = function() {
if (!this.scanCancelled_) {
+ // Just before inserting entries into the file list, check and avoid
+ // duplication.
+ var currentURLs = {};
+ for (var i = 0; i < this.fileList_.length; i++)
+ currentURLs[this.fileList_.item(i).toURL()] = true;
fukino 2014/10/27 05:09:49 This duplication check add some cost, but this doe
+ entriesFiltered = entriesFiltered.filter(function(entry) {
+ return !currentURLs[entry.toURL()];
+ });
// Update the filelist without waiting the metadata.
this.fileList_.push.apply(this.fileList_, entriesFiltered);
cr.dispatchSimpleEvent(this, 'scan-updated');
« 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