Skip to content

Commit f2be717

Browse files
committed
fix: webkit add all files at once
1 parent b3d3e34 commit f2be717

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/resumable.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,8 @@
180180
*/
181181
webkitReadDataTransfer: function (event) {
182182
var $ = this;
183+
var queue = event.dataTransfer.items.length;
184+
var files = [];
183185
each(event.dataTransfer.items, function (item) {
184186
var entry = item.webkitGetAsEntry();
185187
if (!entry) {
@@ -193,6 +195,7 @@
193195
}
194196
});
195197
function readSuccess(entries) {
198+
queue += entries.length;
196199
each(entries, function(entry) {
197200
if (entry.isFile) {
198201
var fullPath = entry.fullPath;
@@ -203,15 +206,22 @@
203206
entry.createReader().readEntries(readSuccess, readError);
204207
}
205208
});
209+
decrement();
206210
}
207211
function fileReadSuccess(file, fullPath) {
208212
// relative path should not start with "/"
209213
file.relativePath = fullPath.substring(1);
210-
$.addFile(file, event);
214+
files.push(file);
215+
decrement();
211216
}
212217
function readError(fileError) {
213218
throw fileError;
214219
}
220+
function decrement() {
221+
if (--queue == 0) {
222+
$.addFiles(files, event);
223+
}
224+
}
215225
},
216226

217227
/**

0 commit comments

Comments
 (0)