From 0025964b6888cc91da6c417253caa5622e494bdd Mon Sep 17 00:00:00 2001 From: Anton SHEPILOV Date: Thu, 19 Dec 2024 18:33:43 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9BThrow=20write=20exception=20with=20?= =?UTF-8?q?proper=20storage=20identifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/oneof-storage-strategy.ts | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tdrive/backend/node/src/core/platform/services/storage/oneof-storage-strategy.ts b/tdrive/backend/node/src/core/platform/services/storage/oneof-storage-strategy.ts index 5d0a8569..e366bedd 100644 --- a/tdrive/backend/node/src/core/platform/services/storage/oneof-storage-strategy.ts +++ b/tdrive/backend/node/src/core/platform/services/storage/oneof-storage-strategy.ts @@ -70,18 +70,21 @@ export class OneOfStorageStrategy implements StorageConnectorAPI { ); // Log all errors and throw if all write operations fail - const errors = writeResults.filter(result => result.status === "rejected"); - errors.forEach((error, index) => { - const storageId = this.storages[index].getId(); - logger.error( - new OneOfStorageWriteOneFailedException( - storageId, - `Error writing to storage ${storageId}`, - (error as PromiseRejectedResult).reason, - ), - ); + let errorsCount = 0; + writeResults.forEach((result, index) => { + if (result.status === "rejected") { + const storageId = this.storages[index].getId(); + logger.error( + new OneOfStorageWriteOneFailedException( + storageId, + `Error writing to storage ${storageId}`, + (result as PromiseRejectedResult).reason, + ), + ); + errorsCount++; + } }); - if (errors.length === this.storages.length) { + if (errorsCount === this.storages.length) { throw new WriteFileException(`Write ${path} failed for all storages`); }