diff --git a/src/upchunk.ts b/src/upchunk.ts index b2be73b..08f7401 100644 --- a/src/upchunk.ts +++ b/src/upchunk.ts @@ -48,6 +48,7 @@ export class UpChunk { private attemptCount: number; private offline: boolean; private paused: boolean; + private success: boolean; private currentXhr?: XMLHttpRequest; private reader: FileReader; @@ -69,6 +70,7 @@ export class UpChunk { this.attemptCount = 0; this.offline = false; this.paused = false; + this.success = false; this.reader = new FileReader(); this.eventTarget = new EventTarget(); @@ -289,7 +291,7 @@ export class UpChunk { * handle errors & retries and dispatch events */ private sendChunks() { - if (this.paused || this.offline) { + if (this.paused || this.offline || this.success) { return; } @@ -311,6 +313,7 @@ export class UpChunk { if (this.chunkCount < this.totalChunks) { this.sendChunks(); } else { + this.success = true; this.dispatch('success'); }