Skip to content

Commit 7db8403

Browse files
committed
call generateUniqueIdentifier once per added file
1 parent 62bdf5e commit 7db8403

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

src/flow.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -583,11 +583,13 @@
583583
var files = [];
584584
each(fileList, function (file) {
585585
// https://github.com/flowjs/flow.js/issues/55
586-
if ((!ie10plus || ie10plus && file.size > 0) && !(file.size % 4096 === 0 && (file.name === '.' || file.fileName === '.')) &&
587-
(this.opts.allowDuplicateUploads || !this.getFromUniqueIdentifier(this.generateUniqueIdentifier(file)))) {
588-
var f = new FlowFile(this, file);
589-
if (this.fire('fileAdded', f, event)) {
590-
files.push(f);
586+
if ((!ie10plus || ie10plus && file.size > 0) && !(file.size % 4096 === 0 && (file.name === '.' || file.fileName === '.'))) {
587+
var uniqueIdentifier = this.generateUniqueIdentifier(file);
588+
if (this.opts.allowDuplicateUploads || !this.getFromUniqueIdentifier(uniqueIdentifier)) {
589+
var f = new FlowFile(this, file, uniqueIdentifier);
590+
if (this.fire('fileAdded', f, event)) {
591+
files.push(f);
592+
}
591593
}
592594
}
593595
}, this);
@@ -695,9 +697,10 @@
695697
* @name FlowFile
696698
* @param {Flow} flowObj
697699
* @param {File} file
700+
* @param {string} uniqueIdentifier
698701
* @constructor
699702
*/
700-
function FlowFile(flowObj, file) {
703+
function FlowFile(flowObj, file, uniqueIdentifier) {
701704

702705
/**
703706
* Reference to parent Flow instance
@@ -739,7 +742,7 @@
739742
* File unique identifier
740743
* @type {string}
741744
*/
742-
this.uniqueIdentifier = flowObj.generateUniqueIdentifier(file);
745+
this.uniqueIdentifier = uniqueIdentifier;
743746

744747
/**
745748
* List of chunks

0 commit comments

Comments
 (0)