chore(local-file): throw error if file exist (#10087)

This commit is contained in:
Carlos R. L. Rodrigues
2024-11-14 12:11:37 -03:00
committed by GitHub
parent 273960f6e3
commit 06ce16c90b
2 changed files with 10 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@medusajs/file-local": patch
---
Throw error from local file provider
@@ -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