diff --git a/components/views/files/controls/Controls.vue b/components/views/files/controls/Controls.vue index b14148f109..09f1bae7ec 100644 --- a/components/views/files/controls/Controls.vue +++ b/components/views/files/controls/Controls.vue @@ -85,14 +85,17 @@ export default Vue.extend({ const originalFiles: File[] = [...event.target.files] // todo - for now, index is stored in the bucket. we could try moving it to the thread, then sat.json wouldn't be reserved - const protectedNameFiles: File[] = originalFiles.filter( + const protectedNameResults: File[] = originalFiles.filter( (file) => !(file.name === 'sat.json'), ) - const sameNameResults: File[] = protectedNameFiles.filter( - (file: File) => { - return !this.$FileSystem.hasChild(file.name) - }, + // filter out files with 0 bytes size + const emptyFileResults: File[] = protectedNameResults.filter( + (file) => !(file.size === 0), ) + // filter out files with the same name as another file + const sameNameResults: File[] = emptyFileResults.filter((file) => { + return !this.$FileSystem.hasChild(file.name) + }) const nsfwResults: Promise<{ file: File; nsfw: boolean }>[] = sameNameResults.map(async (file: File) => { // todo - fix with AP-807. don't scan large files to prevent crash @@ -149,10 +152,13 @@ export default Vue.extend({ this.$emit('forceRender') - if (protectedNameFiles.length !== originalFiles.length) { + if (originalFiles.length !== protectedNameResults.length) { this.errors.push(this.$t('pages.files.errors.reserved_name') as string) } - if (sameNameResults.length !== protectedNameFiles.length) { + if (protectedNameResults.length !== emptyFileResults.length) { + this.errors.push(this.$t('pages.files.errors.empty_file') as string) + } + if (emptyFileResults.length !== sameNameResults.length) { this.errors.push(this.$t('pages.files.errors.file_name') as string) } if (nsfwResults.length !== files.length) { diff --git a/cypress b/cypress index a2f34f57fa..6f2ac355fc 160000 --- a/cypress +++ b/cypress @@ -1 +1 @@ -Subproject commit a2f34f57fa7476f2c96824c4d15542b344f06f73 +Subproject commit 6f2ac355fc714de721ff4df5de6d70ac781fe2df diff --git a/locales/en-US.js b/locales/en-US.js index 330a2c8ac1..fa4a7787ac 100644 --- a/locales/en-US.js +++ b/locales/en-US.js @@ -150,6 +150,7 @@ export default { }, errors: { reserved_name: 'sat.json is a reserved file name', + empty_file: 'File needs to have a size of 1 byte or greater', file_name: 'File with name already exists in this file system', }, },