don't add zero length files (also directories)

This commit is contained in:
Danny Coates 2019-01-03 16:12:40 -08:00
parent 5e5af03d11
commit 8c496e3bee
No known key found for this signature in database
GPG Key ID: 4C442633C62E00CB
1 changed files with 3 additions and 1 deletions

View File

@ -53,7 +53,9 @@ export default class Archive {
if (this.files.length + files.length > LIMITS.MAX_FILES_PER_ARCHIVE) { if (this.files.length + files.length > LIMITS.MAX_FILES_PER_ARCHIVE) {
throw new Error('tooManyFiles'); throw new Error('tooManyFiles');
} }
const newFiles = files.filter(file => !isDupe(file, this.files)); const newFiles = files.filter(
file => file.size > 0 && !isDupe(file, this.files)
);
const newSize = newFiles.reduce((total, file) => total + file.size, 0); const newSize = newFiles.reduce((total, file) => total + file.size, 0);
if (this.size + newSize > maxSize) { if (this.size + newSize > maxSize) {
throw new Error('fileTooBig'); throw new Error('fileTooBig');