chore(local-file): throw error if file exist (#10087)
This commit is contained in:
@@ -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)
|
const filePath = this.getUploadFilePath(baseDir, file.fileKey)
|
||||||
try {
|
try {
|
||||||
await fs.access(filePath, fs.constants.F_OK)
|
await fs.access(filePath, fs.constants.W_OK)
|
||||||
await fs.unlink(filePath)
|
await fs.unlink(filePath)
|
||||||
} catch (e) {
|
} 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
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user