From d2f441111275b0ebbc21d8b002e2b54a277dd8bc Mon Sep 17 00:00:00 2001 From: Eric Doughty-Papassideris Date: Mon, 10 Mar 2025 14:00:45 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20back=20e2e:=20bug=20fix=20for=20?= =?UTF-8?q?local=20storage=20to=20emulate=20S3=20semantics?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../storage/connectors/local/service.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tdrive/backend/node/src/core/platform/services/storage/connectors/local/service.ts b/tdrive/backend/node/src/core/platform/services/storage/connectors/local/service.ts index 8bbfe0bf..303be390 100644 --- a/tdrive/backend/node/src/core/platform/services/storage/connectors/local/service.ts +++ b/tdrive/backend/node/src/core/platform/services/storage/connectors/local/service.ts @@ -96,7 +96,13 @@ export default class LocalConnectorService implements StorageConnectorAPI { } delete(path: string): Promise { - return rm(this.getFullPath(path), { recursive: false, force: true }); + try { + return rm(this.getFullPath(path), { recursive: false, force: true }); + } catch (err) { + // Follow S3 convention of silently ignoring missing paths + if (err?.code === "ENOENT") return; + throw err; + } } async exists(path: string): Promise { @@ -106,8 +112,15 @@ export default class LocalConnectorService implements StorageConnectorAPI { } async enumeratePathsForFile(filePath: string): Promise { - return (await fs.promises.readdir(this.getFullPath(filePath), { recursive: true })).map( - item => filePath + "/" + item, - ); + try { + return (await fs.promises.readdir(this.getFullPath(filePath), { recursive: true })).map( + item => filePath + "/" + item, + ); + } catch (err) { + logger.error({ err, filePath }, "Error enumerating local folder"); + // Follow S3 convention of silently ignoring missing paths + if (err?.code === "ENOENT") return []; + throw err; + } } }