|
@@ -496,7 +496,7 @@ export default class Tus extends BasePlugin {
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
const token = file.serverToken
|
|
const token = file.serverToken
|
|
const host = getSocketHost(file.remote.companionUrl)
|
|
const host = getSocketHost(file.remote.companionUrl)
|
|
- const socket = new Socket({ target: `${host}/api/${token}` })
|
|
|
|
|
|
+ const socket = new Socket({ target: `${host}/api/${token}`, autoOpen: false })
|
|
this.uploaderSockets[file.id] = socket
|
|
this.uploaderSockets[file.id] = socket
|
|
this.uploaderEvents[file.id] = new EventTracker(this.uppy)
|
|
this.uploaderEvents[file.id] = new EventTracker(this.uppy)
|
|
|
|
|
|
@@ -519,8 +519,10 @@ export default class Tus extends BasePlugin {
|
|
// resume a queued upload to make it skip the queue.
|
|
// resume a queued upload to make it skip the queue.
|
|
queuedRequest.abort()
|
|
queuedRequest.abort()
|
|
queuedRequest = this.requests.run(() => {
|
|
queuedRequest = this.requests.run(() => {
|
|
|
|
+ socket.open()
|
|
socket.send('resume', {})
|
|
socket.send('resume', {})
|
|
- return () => {}
|
|
|
|
|
|
+
|
|
|
|
+ return () => socket.close()
|
|
})
|
|
})
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -545,8 +547,10 @@ export default class Tus extends BasePlugin {
|
|
socket.send('pause', {})
|
|
socket.send('pause', {})
|
|
}
|
|
}
|
|
queuedRequest = this.requests.run(() => {
|
|
queuedRequest = this.requests.run(() => {
|
|
|
|
+ socket.open()
|
|
socket.send('resume', {})
|
|
socket.send('resume', {})
|
|
- return () => {}
|
|
|
|
|
|
+
|
|
|
|
+ return () => socket.close()
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
|
|
@@ -607,15 +611,17 @@ export default class Tus extends BasePlugin {
|
|
queuedRequest = this.requests.run(() => {
|
|
queuedRequest = this.requests.run(() => {
|
|
if (file.isPaused) {
|
|
if (file.isPaused) {
|
|
socket.send('pause', {})
|
|
socket.send('pause', {})
|
|
|
|
+ } else {
|
|
|
|
+ socket.open()
|
|
}
|
|
}
|
|
|
|
|
|
- // Don't do anything here, the caller will take care of cancelling the upload itself
|
|
|
|
|
|
+ // Just close the socket here, the caller will take care of cancelling the upload itself
|
|
// using resetUploaderReferences(). This is because resetUploaderReferences() has to be
|
|
// using resetUploaderReferences(). This is because resetUploaderReferences() has to be
|
|
// called when this request is still in the queue, and has not been started yet, too. At
|
|
// called when this request is still in the queue, and has not been started yet, too. At
|
|
// that point this cancellation function is not going to be called.
|
|
// that point this cancellation function is not going to be called.
|
|
// Also, we need to remove the request from the queue _without_ destroying everything
|
|
// Also, we need to remove the request from the queue _without_ destroying everything
|
|
// related to this upload to handle pauses.
|
|
// related to this upload to handle pauses.
|
|
- return () => {}
|
|
|
|
|
|
+ return () => socket.close()
|
|
})
|
|
})
|
|
})
|
|
})
|
|
}
|
|
}
|