Volafile / volafile-bugs

Volafile.org public bug tracker
17 stars 2 forks source link

Safari double upload bug #241

Closed RealDolos closed 5 years ago

RealDolos commented 5 years ago

When using Safari (desktop, maybe mobile) and uploading by clicking the upload button, then the file is queued and uploaded twice.

RealDolos commented 5 years ago

This happens because webkitEntries is a quirky asshole... In Chrome (and firefox that emulates chrome) it's either .webkitEntries or .files that gets populated (also depending on whether it was dnd), but not both. Safari however populates both....

You got code like this (deminified):

key: "onFilesSelected",
            value: function() {
                var t, e, n = this;
                this.import("header").submitName(),
                t = this.uploadInput,
                e = function(t) {
                    0 < t.length && n.import("upload").addUploads(t),
                    n.swapUploadInput()
                }
                ,
                t.webkitEntries && p(t.webkitEntries, e),
                e(t.files || [])
            }

calls e(t.webkitEntries) when it's present and always e(t.files). In Chrome and fx, .files will be an empty array when .webkitEntries is not, and vice versa, so no problem (except for some unnecessary calls). In Safari, both might be populated, so effectively e() gets called twice.

The solution here is to only call e(t.files) when !t.webkitEntries || !t.webkitEntries.length.

laino commented 5 years ago

fixed upstream