Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit concurrent uploads to one #2653

Merged
merged 1 commit into from
Dec 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/files/src/components/PublicLinks/FilesDrop.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ export default {
this.uploadedFilesChangeTracker++
this.uploadedFiles.set(uploadId, { name: event.name, size: event.size, status: 'init' })

this.$client.publicFiles.putFileContents(this.publicLinkToken, event.name, this.publicLinkPassword, event, {
this.uploadQueue.add(() => this.$client.publicFiles.putFileContents(this.publicLinkToken, event.name, this.publicLinkPassword, event, {
// automatically rename in case of duplicates
headers: { 'OC-Autorename': 1 },
onProgress: (progressEvent) => {
this.uploadedFilesChangeTracker++
this.uploadedFiles.set(uploadId, { name: event.name, size: event.size, status: 'uploading' })
}
}).then(e => {
})).then(e => {
this.uploadedFilesChangeTracker++
this.uploadedFiles.set(uploadId, { name: event.name, size: event.size, status: 'done' })
}).catch(e => {
Expand Down
15 changes: 8 additions & 7 deletions apps/files/src/mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default {
}
},
data: () => ({
queue: new PQueue({ concurrency: 1 }),
uploadQueue: new PQueue({ concurrency: 1 }),
directoryQueue: new PQueue({ concurrency: 1 }),
uploadFileUniqueId: 0
}),
computed: {
Expand Down Expand Up @@ -226,9 +227,9 @@ export default {
let p

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

createFolderPromises.push(p)
Expand Down Expand Up @@ -284,21 +285,21 @@ export default {
const token = basePath.substr(0, tokenSplit)
basePath = basePath.substr(tokenSplit + 1) || ''
relativePath = join(basePath, relativePath)
promise = this.$client.publicFiles.putFileContents(token, relativePath, this.publicLinkPassword, file, {
promise = this.uploadQueue.add(() => this.$client.publicFiles.putFileContents(token, relativePath, this.publicLinkPassword, file, {
onProgress: (progress) => {
this.$_ocUpload_onProgress(progress, file)
},
overwrite: overwrite
})
}))
} else {
basePath = this.path || ''
relativePath = join(basePath, relativePath)
promise = this.$client.files.putFileContents(relativePath, file, {
promise = this.uploadQueue.add(() => this.$client.files.putFileContents(relativePath, file, {
onProgress: (progress) => {
this.$_ocUpload_onProgress(progress, file)
},
overwrite: overwrite
})
}))
}

promise.then(e => {
Expand Down