Skip to content

Commit

Permalink
chore(local-file): throw error if file exist (#10087)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlos-r-l-rodrigues authored Nov 14, 2024
1 parent 273960f commit 06ce16c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/rich-pumpkins-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@medusajs/file-local": patch
---

Throw error from local file provider
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06ce16c

Please sign in to comment.