From 84e10fc1f589e3cbafd0d40b72f550f0a7ddf942 Mon Sep 17 00:00:00 2001 From: Jack Bentley Date: Mon, 17 Oct 2016 20:18:55 +0100 Subject: [PATCH 1/2] feat(uploader): adds validation option to allow empty file uploads #903 --- client/js/uploader.basic.api.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/js/uploader.basic.api.js b/client/js/uploader.basic.api.js index b2b6086b4..14178c657 100644 --- a/client/js/uploader.basic.api.js +++ b/client/js/uploader.basic.api.js @@ -1795,7 +1795,7 @@ return validityChecker.failure(); } - if (size === 0) { + if (!this._options.validation.allowEmpty && size === 0) { this._itemError("emptyError", name, file); return validityChecker.failure(); } From 8497204eba9e224ab21f9be912608183774eedff Mon Sep 17 00:00:00 2001 From: Jack Bentley Date: Mon, 17 Oct 2016 20:25:09 +0100 Subject: [PATCH 2/2] fix(uploader): fixes wrong file size showing and NaN% showing #903 --- client/js/uploader.api.js | 2 +- client/js/uploader.basic.api.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/js/uploader.api.js b/client/js/uploader.api.js index 2603c4354..2e74c4d65 100644 --- a/client/js/uploader.api.js +++ b/client/js/uploader.api.js @@ -326,7 +326,7 @@ this._templating.updateProgress(id, loaded, total); - if (Math.round(loaded / total * 100) === 100) { + if (total === 0 || Math.round(loaded / total * 100) === 100) { this._templating.hideCancel(id); this._templating.hidePause(id); this._templating.hideProgress(id); diff --git a/client/js/uploader.basic.api.js b/client/js/uploader.basic.api.js index 14178c657..03bea64e8 100644 --- a/client/js/uploader.basic.api.js +++ b/client/js/uploader.basic.api.js @@ -795,6 +795,10 @@ }, _formatSize: function(bytes) { + if (bytes === 0) { + return bytes + this._options.text.sizeSymbols[0]; + } + var i = -1; do { bytes = bytes / 1000;