Skip to content

Commit

Permalink
Merge pull request #2210 from owncloud/bugfix/folder-upload-queue
Browse files Browse the repository at this point in the history
Use PQueue to run only one create folder promise in folder upload
  • Loading branch information
DeepDiver1975 authored Oct 10, 2019
2 parents ccd4756 + 22673e4 commit eeb651b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/files/src/components/UploadMenu.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<ul class="uk-list uk-margin-remove">
<li v-for="(item, index) in items" :key="item.name">
<li v-for="(item, index) in items" :key="item.id">
<div class="uk-flex">
<oc-icon name="file_copy" class="uk-margin-small-right" />
<div class="uk-width-expand">
Expand Down
15 changes: 12 additions & 3 deletions apps/files/src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import moment from 'moment'
import FileUpload from './FileUpload.js'
import fileTypeIconMappings from './fileTypeIconMappings.json'
import { mapActions, mapGetters } from 'vuex'
const { default: PQueue } = require('p-queue')

export default {
filters: {
Expand All @@ -27,7 +28,9 @@ export default {
changeFileName: false,
fileToBeDeleted: '',
newName: '',
originalName: null
originalName: null,
queue: new PQueue({ concurrency: 1 }),
uploadFileUniqueId: 0
}),
computed: {
...mapGetters('Files', ['searchTerm', 'inProgress', 'files', 'selectedFiles', 'highlightedFile', 'activeFiles']),
Expand Down Expand Up @@ -328,11 +331,15 @@ export default {
const createFolderPromises = []
const rootDir = directoriesToCreate[0]
for (const directory of directoriesToCreate) {
let p

if (this.publicPage()) {
createFolderPromises.push(this.$client.publicFiles.createFolder(this.rootPath + directory))
p = this.queue.add(() => this.$client.publicFiles.createFolder(this.rootPath + directory))
} else {
createFolderPromises.push(this.$client.files.createFolder(this.rootPath + directory))
p = this.queue.add(() => this.$client.files.createFolder(this.rootPath + directory))
}

createFolderPromises.push(p)
}
// Upload files
const uploadPromises = []
Expand Down Expand Up @@ -361,6 +368,8 @@ export default {
})
},
$_ocUpload (file, path, overwrite = null, emitSuccess = true) {
file.id = this.uploadFileUniqueId
this.uploadFileUniqueId++
this.addFileToProgress(file)
const fileUpload = new FileUpload(file, path, this.url, this.headers, this.$_ocUpload_onProgress, this.requestType)
return fileUpload
Expand Down

0 comments on commit eeb651b

Please sign in to comment.