Skip to content

Commit a229aa9

Browse files
committed
chore: throw helpful error if name exists
1 parent b23ef89 commit a229aa9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/bundles/files/actions.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,17 @@ const actions = () => ({
415415
const cid = result[0].root.cid
416416
const src = `/ipfs/${cid}`
417417
const dst = realMfsPath(join(root, name))
418+
let dstExists = false
419+
420+
// Check if destination path already exists
421+
await ipfs.files.stat(dst).then(() => {
422+
dstExists = true
423+
})
424+
425+
if (dstExists) {
426+
throw new Error(`The name "${name}" already exists in the current directory. Try importing with a different name.`)
427+
}
428+
418429
try {
419430
await ipfs.files.cp(src, dst)
420431
} catch (err) {

0 commit comments

Comments
 (0)