Commit 2a724e66 authored by fukino's avatar fukino Committed by Commit bot

Avoid inserting duplicated entries after creating a directory.

New entries which are passed to DirectoryContents.onNewEntries_ are determined in DorectoryContents.update, but before they are inserted in the file list, the file list may change.
When creating a new directory in Drive, this sometimes occurs.
This CL adds duplication check just before inserting entries.

BUG=423646
TEST=creating a directory in MyDrive By Ctrl-E and check if there's no duplicated folder.

Review URL: https://codereview.chromium.org/676293002

Cr-Commit-Position: refs/heads/master@{#301335}
parent 61297e59
......@@ -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;
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');
......
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