Skip to content

Commit e1c63ce

Browse files
d-googshaffeeullah
andauthored
refactor: remove unused restart private method (#2038)
Co-authored-by: Sameena Shaffeeullah <[email protected]>
1 parent 4467035 commit e1c63ce

File tree

2 files changed

+0
-74
lines changed

2 files changed

+0
-74
lines changed

src/resumable-upload.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -899,25 +899,6 @@ export class Upload extends Writable {
899899
return successfulRequest ? res : null;
900900
}
901901

902-
private restart() {
903-
if (this.numBytesWritten) {
904-
const message =
905-
'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.';
906-
907-
this.emit('error', new RangeError(message));
908-
return;
909-
}
910-
911-
this.lastChunkSent = Buffer.alloc(0);
912-
this.createURI(err => {
913-
if (err) {
914-
return this.destroy(err);
915-
}
916-
this.startUploading();
917-
return;
918-
});
919-
}
920-
921902
/**
922903
* @return {bool} is the request good?
923904
*/

test/resumable-upload.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,61 +1679,6 @@ describe('resumable-upload', () => {
16791679
});
16801680
});
16811681

1682-
describe('#restart', () => {
1683-
beforeEach(() => {
1684-
up.createURI = () => {};
1685-
});
1686-
1687-
it('should throw if `numBytesWritten` is not 0', done => {
1688-
up.numBytesWritten = 8;
1689-
1690-
up.on('error', (error: Error) => {
1691-
assert(error instanceof RangeError);
1692-
assert(
1693-
/Attempting to restart an upload after unrecoverable bytes have been written/.test(
1694-
error.message
1695-
)
1696-
);
1697-
done();
1698-
});
1699-
1700-
up.restart();
1701-
});
1702-
1703-
describe('starting a new upload', () => {
1704-
it('should create a new URI', done => {
1705-
up.createURI = () => {
1706-
done();
1707-
};
1708-
1709-
up.restart();
1710-
});
1711-
1712-
it('should destroy stream if it cannot create a URI', done => {
1713-
const error = new Error(':(');
1714-
1715-
up.createURI = (callback: Function) => {
1716-
callback(error);
1717-
};
1718-
1719-
up.destroy = (err: Error) => {
1720-
assert.strictEqual(err, error);
1721-
done();
1722-
};
1723-
1724-
up.restart();
1725-
});
1726-
1727-
it('should start uploading', done => {
1728-
up.createURI = (callback: Function) => {
1729-
up.startUploading = done;
1730-
callback();
1731-
};
1732-
up.restart();
1733-
});
1734-
});
1735-
});
1736-
17371682
describe('#onResponse', () => {
17381683
beforeEach(() => {
17391684
up.numRetries = 0;

0 commit comments

Comments
 (0)