diff --git a/services/filestore/app/js/GcsPersistor.js b/services/filestore/app/js/GcsPersistor.js index 61b3e814b0..50cac9bda8 100644 --- a/services/filestore/app/js/GcsPersistor.js +++ b/services/filestore/app/js/GcsPersistor.js @@ -53,18 +53,7 @@ const GcsPersistor = { module.exports = GcsPersistor async function sendFile(bucketName, key, fsPath) { - let readStream - try { - readStream = fs.createReadStream(fsPath) - } catch (err) { - throw PersistorHelper.wrapError( - err, - 'error reading file from disk', - { bucketName, key, fsPath }, - ReadError - ) - } - return sendStream(bucketName, key, readStream) + return sendStream(bucketName, key, fs.createReadStream(fsPath)) } async function sendStream(bucketName, key, readStream, sourceMd5) { diff --git a/services/filestore/app/js/S3Persistor.js b/services/filestore/app/js/S3Persistor.js index 4403386716..1b92a61ae6 100644 --- a/services/filestore/app/js/S3Persistor.js +++ b/services/filestore/app/js/S3Persistor.js @@ -46,18 +46,7 @@ const S3Persistor = { module.exports = S3Persistor async function sendFile(bucketName, key, fsPath) { - let readStream - try { - readStream = fs.createReadStream(fsPath) - } catch (err) { - throw PersistorHelper.wrapError( - err, - 'error reading file from disk', - { bucketName, key, fsPath }, - ReadError - ) - } - return sendStream(bucketName, key, readStream) + return sendStream(bucketName, key, fs.createReadStream(fsPath)) } async function sendStream(bucketName, key, readStream, sourceMd5) { diff --git a/services/filestore/test/unit/js/GcsPersistorTests.js b/services/filestore/test/unit/js/GcsPersistorTests.js index 97b049e833..bdd7e1d562 100644 --- a/services/filestore/test/unit/js/GcsPersistorTests.js +++ b/services/filestore/test/unit/js/GcsPersistorTests.js @@ -440,48 +440,6 @@ describe('GcsPersistorTests', function() { ) }) }) - - describe('when the file does not exist', function() { - let error - - beforeEach(async function() { - Fs.createReadStream = sinon.stub().throws(FileNotFoundError) - try { - await GcsPersistor.promises.sendFile(bucket, key, filename) - } catch (err) { - error = err - } - }) - - it('returns a NotFoundError', function() { - expect(error).to.be.an.instanceOf(Errors.NotFoundError) - }) - - it('wraps the error', function() { - expect(error.cause).to.equal(FileNotFoundError) - }) - }) - - describe('when reading the file throws an error', function() { - let error - - beforeEach(async function() { - Fs.createReadStream = sinon.stub().throws(genericError) - try { - await GcsPersistor.promises.sendFile(bucket, key, filename) - } catch (err) { - error = err - } - }) - - it('returns a ReadError', function() { - expect(error).to.be.an.instanceOf(Errors.ReadError) - }) - - it('wraps the error', function() { - expect(error.cause).to.equal(genericError) - }) - }) }) describe('copyFile', function() { diff --git a/services/filestore/test/unit/js/S3PersistorTests.js b/services/filestore/test/unit/js/S3PersistorTests.js index aa9444428e..484a0209a8 100644 --- a/services/filestore/test/unit/js/S3PersistorTests.js +++ b/services/filestore/test/unit/js/S3PersistorTests.js @@ -583,48 +583,6 @@ describe('S3PersistorTests', function() { }) }) }) - - describe('when the file does not exist', function() { - let error - - beforeEach(async function() { - Fs.createReadStream = sinon.stub().throws(FileNotFoundError) - try { - await S3Persistor.promises.sendFile(bucket, key, filename) - } catch (err) { - error = err - } - }) - - it('returns a NotFoundError', function() { - expect(error).to.be.an.instanceOf(Errors.NotFoundError) - }) - - it('wraps the error', function() { - expect(error.cause).to.equal(FileNotFoundError) - }) - }) - - describe('when reading the file throws an error', function() { - let error - - beforeEach(async function() { - Fs.createReadStream = sinon.stub().throws(genericError) - try { - await S3Persistor.promises.sendFile(bucket, key, filename) - } catch (err) { - error = err - } - }) - - it('returns a ReadError', function() { - expect(error).to.be.an.instanceOf(Errors.ReadError) - }) - - it('wraps the error', function() { - expect(error.cause).to.equal(genericError) - }) - }) }) describe('copyFile', function() {