Skip to content

Commit

Permalink
fix(dataTrasnfer): fail when a DataTransferErrorCommand is received
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Van Camp committed Oct 4, 2018
1 parent d8b2d5f commit 441ef68
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/dataTransfer/dataLock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,13 @@ export default class DataLock {
this.commandQueue.push(command)
}
}

transferErrored (code: number) {
if (this.transfer) {
// @todo: dequeue any old commands
this.transfer.fail(code)
}
this.transfer = undefined
this.dequeueAndRun()
}
}
2 changes: 1 addition & 1 deletion src/dataTransfer/dataTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default abstract class DataTransfer {
commandQueue: Array<Commands.AbstractCommand>

finish: (transfer: DataTransfer) => void
fail: () => void
fail: (errorCode?: number) => void
abstract start (): void

abstract handleCommand (command: Commands.AbstractCommand): void
Expand Down
3 changes: 3 additions & 0 deletions src/dataTransfer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export class DataTransferManager {
if (!command.properties.locked) lock.lostLock()
else lock.updateLock(command.properties.locked)
}
if (command.constructor.name === Commands.DataTransferErrorCommand.name) {
lock.transferErrored(command.properties.errorCode)
}
if (lock.transfer) {
lock.transfer.handleCommand(command)
if (lock.transfer.state === Enums.TransferState.Finished) {
Expand Down

0 comments on commit 441ef68

Please sign in to comment.