Skip to content

Commit

Permalink
refactor: remove unused restart private method (#2038)
Browse files Browse the repository at this point in the history
Co-authored-by: Sameena Shaffeeullah <shaffeeullah@google.com>
  • Loading branch information
danielbankhead and shaffeeullah committed Aug 12, 2022
1 parent 4467035 commit e1c63ce
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 74 deletions.
19 changes: 0 additions & 19 deletions src/resumable-upload.ts
Expand Up @@ -899,25 +899,6 @@ export class Upload extends Writable {
return successfulRequest ? res : null;
}

private restart() {
if (this.numBytesWritten) {
const message =
'Attempting to restart an upload after unrecoverable bytes have been written from upstream. Stopping as this could result in data loss. Initiate a new upload to continue.';

this.emit('error', new RangeError(message));
return;
}

this.lastChunkSent = Buffer.alloc(0);
this.createURI(err => {
if (err) {
return this.destroy(err);
}
this.startUploading();
return;
});
}

/**
* @return {bool} is the request good?
*/
Expand Down
55 changes: 0 additions & 55 deletions test/resumable-upload.ts
Expand Up @@ -1679,61 +1679,6 @@ describe('resumable-upload', () => {
});
});

describe('#restart', () => {
beforeEach(() => {
up.createURI = () => {};
});

it('should throw if `numBytesWritten` is not 0', done => {
up.numBytesWritten = 8;

up.on('error', (error: Error) => {
assert(error instanceof RangeError);
assert(
/Attempting to restart an upload after unrecoverable bytes have been written/.test(
error.message
)
);
done();
});

up.restart();
});

describe('starting a new upload', () => {
it('should create a new URI', done => {
up.createURI = () => {
done();
};

up.restart();
});

it('should destroy stream if it cannot create a URI', done => {
const error = new Error(':(');

up.createURI = (callback: Function) => {
callback(error);
};

up.destroy = (err: Error) => {
assert.strictEqual(err, error);
done();
};

up.restart();
});

it('should start uploading', done => {
up.createURI = (callback: Function) => {
up.startUploading = done;
callback();
};
up.restart();
});
});
});

describe('#onResponse', () => {
beforeEach(() => {
up.numRetries = 0;
Expand Down

0 comments on commit e1c63ce

Please sign in to comment.