From 18f21b1a33348683955656ed1e0cdd780c5360dc Mon Sep 17 00:00:00 2001 From: "Carlos R. L. Rodrigues" Date: Wed, 13 Nov 2024 15:19:31 -0300 Subject: [PATCH] chore(local-file): throw error if file exist --- .changeset/rich-pumpkins-lie.md | 5 +++++ .../providers/file-local/src/services/local-file.ts | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 .changeset/rich-pumpkins-lie.md diff --git a/.changeset/rich-pumpkins-lie.md b/.changeset/rich-pumpkins-lie.md new file mode 100644 index 0000000000000..49ae17a49a420 --- /dev/null +++ b/.changeset/rich-pumpkins-lie.md @@ -0,0 +1,5 @@ +--- +"@medusajs/file-local": patch +--- + +Throw error from local file provider diff --git a/packages/modules/providers/file-local/src/services/local-file.ts b/packages/modules/providers/file-local/src/services/local-file.ts index b5001a6256155..b03fe5d7c5006 100644 --- a/packages/modules/providers/file-local/src/services/local-file.ts +++ b/packages/modules/providers/file-local/src/services/local-file.ts @@ -71,10 +71,13 @@ export class LocalFileService extends AbstractFileProviderService { const filePath = this.getUploadFilePath(baseDir, file.fileKey) try { - await fs.access(filePath, fs.constants.F_OK) + await fs.access(filePath, fs.constants.W_OK) await fs.unlink(filePath) } catch (e) { - // The file does not exist, so it's a noop. + // The file does not exist, we don't do anything + if (e.code !== "ENOENT") { + throw e + } } return