mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-05-27 14:54:42 +00:00
Fixed issue when you upload empty .txt file, it stops the upload process
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
- Fixed issue when you perform composer update with private repository
|
- Fixed issue when you perform composer update with private repository
|
||||||
- Fixed issue where change in sorting option will duplicate the content in file view
|
- Fixed issue where change in sorting option will duplicate the content in file view
|
||||||
- Fixed issue where Dragged & Dropped folder from desktop didn't start uploading
|
- Fixed issue where Dragged & Dropped folder from desktop didn't start uploading
|
||||||
|
- Fixed issue when you upload empty .txt file, it stops the upload process
|
||||||
|
|
||||||
## Version 2.2.0.6
|
## Version 2.2.0.6
|
||||||
#### Release date: 13. Jun 2022
|
#### Release date: 13. Jun 2022
|
||||||
|
|||||||
+13
-49
@@ -178,24 +178,22 @@ const FunctionHelpers = {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (files.length === 0) return
|
if (files.length === 0) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.$checkFileMimetype(files) || !this.$checkUploadLimit(files)) return // Push items to file queue
|
if (!this.$checkFileMimetype(files) || !this.$checkUploadLimit(files)) {
|
||||||
;[...files].map((item) => {
|
return
|
||||||
store.commit('ADD_FILES_TO_QUEUE', {
|
}
|
||||||
|
|
||||||
|
// Push items to file queue
|
||||||
|
[...files].map((item) => {
|
||||||
|
store.dispatch('pushFileToTheUploadQueue', {
|
||||||
parent_id: store.getters.currentFolder ? store.getters.currentFolder.data.id : '',
|
parent_id: store.getters.currentFolder ? store.getters.currentFolder.data.id : '',
|
||||||
file: item,
|
file: item,
|
||||||
path: '/' + item.webkitRelativePath,
|
path: '/' + item.webkitRelativePath,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Start uploading if uploading process isn't running
|
|
||||||
if (store.getters.filesInQueueTotal === 0) {
|
|
||||||
this.$handleUploading(store.getters.fileQueue[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase total files in upload bar
|
|
||||||
store.commit('INCREASE_FILES_IN_QUEUES_TOTAL', files.length)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.prototype.$uploadDraggedFolderOrFile = async function (files, parent_id) {
|
Vue.prototype.$uploadDraggedFolderOrFile = async function (files, parent_id) {
|
||||||
@@ -209,46 +207,12 @@ const FunctionHelpers = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Push file to the upload queue
|
// Push file to the upload queue
|
||||||
if (file.name !== '.DS_Store') {
|
store.dispatch('pushFileToTheUploadQueue', {
|
||||||
store.commit('ADD_FILES_TO_QUEUE', {
|
|
||||||
parent_id: parent_id || '',
|
|
||||||
path: filePath,
|
|
||||||
file: file,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// Start uploading if uploading process isn't running
|
|
||||||
if (store.getters.filesInQueueTotal === 0) {
|
|
||||||
this.$handleUploading(store.getters.fileQueue[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase total files in upload bar
|
|
||||||
store.commit('INCREASE_FILES_IN_QUEUES_TOTAL', files.length)
|
|
||||||
}
|
|
||||||
|
|
||||||
Vue.prototype.$uploadDraggedFiles = async function (event, parent_id) {
|
|
||||||
// Show alert message when upload is disabled
|
|
||||||
if (store.getters.user && !store.getters.user.data.meta.restrictions.canUpload) {
|
|
||||||
Vue.prototype.$temporarilyDisabledUpload()
|
|
||||||
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent submit empty files
|
|
||||||
if (event.dataTransfer.items.length === 0) return // Push items to file queue
|
|
||||||
;[...event.dataTransfer.items].map((item) => {
|
|
||||||
store.commit('ADD_FILES_TO_QUEUE', {
|
|
||||||
parent_id: parent_id || '',
|
parent_id: parent_id || '',
|
||||||
file: item.getAsFile(),
|
path: filePath,
|
||||||
|
file: file,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Start uploading if uploading process isn't running
|
|
||||||
if (store.getters.filesInQueueTotal == 0) this.$handleUploading(store.getters.fileQueue[0])
|
|
||||||
|
|
||||||
// Increase total files in upload bar
|
|
||||||
store.commit('INCREASE_FILES_IN_QUEUES_TOTAL', [...event.dataTransfer.items].length)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Vue.prototype.$handleUploading = async function (item) {
|
Vue.prototype.$handleUploading = async function (item) {
|
||||||
|
|||||||
+24
-2
@@ -375,6 +375,28 @@ const actions = {
|
|||||||
})
|
})
|
||||||
.catch(() => Vue.prototype.$isSomethingWrong())
|
.catch(() => Vue.prototype.$isSomethingWrong())
|
||||||
},
|
},
|
||||||
|
pushFileToTheUploadQueue: ({commit, getters}, item) => {
|
||||||
|
// Prevent to upload file with 0kb file size
|
||||||
|
if (item.file.size === 0) {
|
||||||
|
events.$emit('toaster', {
|
||||||
|
type: 'danger',
|
||||||
|
message: `The file ${item.file.name} can't be uploaded`,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.file.size !== 0 && item.file.name !== '.DS_Store') {
|
||||||
|
// commit file to the upload queue
|
||||||
|
commit('ADD_FILES_TO_QUEUE', item)
|
||||||
|
|
||||||
|
// Start uploading if uploading process isn't running
|
||||||
|
if (getters.filesInQueueTotal === 0) {
|
||||||
|
Vue.prototype.$handleUploading(getters.fileQueue[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Increase total files in upload bar
|
||||||
|
commit('INCREASE_FILES_IN_QUEUES_TOTAL')
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const mutations = {
|
const mutations = {
|
||||||
@@ -396,8 +418,8 @@ const mutations = {
|
|||||||
UPLOADING_FILE_PROGRESS(state, percentage) {
|
UPLOADING_FILE_PROGRESS(state, percentage) {
|
||||||
state.uploadingProgress = percentage
|
state.uploadingProgress = percentage
|
||||||
},
|
},
|
||||||
INCREASE_FILES_IN_QUEUES_TOTAL(state, count) {
|
INCREASE_FILES_IN_QUEUES_TOTAL(state) {
|
||||||
state.filesInQueueTotal += count
|
state.filesInQueueTotal += 1
|
||||||
},
|
},
|
||||||
INCREASE_FILES_IN_QUEUE_UPLOADED(state) {
|
INCREASE_FILES_IN_QUEUE_UPLOADED(state) {
|
||||||
state.filesInQueueUploaded++
|
state.filesInQueueUploaded++
|
||||||
|
|||||||
Reference in New Issue
Block a user