From bf76787e494aee7833ea0c2345f767146dfccd54 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 30 Apr 2021 21:37:57 +0200 Subject: [PATCH] fix(fs/S3#_createReadStream): throw ENOENT if file doesn't exist --- @xen-orchestra/fs/src/s3.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/@xen-orchestra/fs/src/s3.js b/@xen-orchestra/fs/src/s3.js index 87cb273bc..db12108bc 100644 --- a/@xen-orchestra/fs/src/s3.js +++ b/@xen-orchestra/fs/src/s3.js @@ -73,9 +73,16 @@ export default class S3Handler extends RemoteHandlerAbstract { return this._s3.putObject({ ...this._createParams(file), Body: data }) } - async _createReadStream(file, options) { + async _createReadStream(path, options) { + if (!(await this._isFile(path))) { + const error = new Error(`ENOENT: no such file '${path}'`) + error.code = 'ENOENT' + error.path = path + throw error + } + // https://github.com/Sullux/aws-sdk/issues/11 - return this._s3.getObject.raw(this._createParams(file)).createReadStream() + return this._s3.getObject.raw(this._createParams(path)).createReadStream() } async _unlink(file) {