tus: clear uploadURL when retrying.

This commit is contained in:
Renée Kooi 2017-10-17 11:52:35 +02:00
parent d7557bd13d
commit e56dc21faa
No known key found for this signature in database
GPG key ID: 30516CF2A8E63718

View file

@ -126,13 +126,11 @@ module.exports = class Tus10 extends Plugin {
})
this.onRetry(file.id, () => {
upload.abort()
upload.start()
this.removeUploadURL(file.id)
})
this.onRetryAll(file.id, () => {
upload.abort()
upload.start()
this.removeUploadURL(file.id)
})
this.onPauseAll(file.id, () => {
@ -141,6 +139,7 @@ module.exports = class Tus10 extends Plugin {
this.onCancelAll(file.id, () => {
upload.abort()
this.removeUploadURL(file.id)
})
this.onResumeAll(file.id, () => {
@ -265,6 +264,19 @@ module.exports = class Tus10 extends Plugin {
}
}
removeUploadURL (fileID) {
const file = this.core.getFile(fileID)
// No need to change state if we didn't have an `uploadUrl`.
if (!file || !file.tus || !file.tus.uploadUrl) return
this.updateFile(Object.assign({}, file, {
tus: Object.assign({}, file.tus, {
uploadUrl: null
})
}))
}
onFileRemove (fileID, cb) {
this.core.on('core:file-removed', (targetFileID) => {
if (fileID === targetFileID) cb(targetFileID)