Skip to content

Commit

Permalink
fix: Add conflict detection to file movement
Browse files Browse the repository at this point in the history
  • Loading branch information
1943time committed Sep 19, 2023
1 parent 79994f1 commit 9833f38
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/renderer/src/store/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ export class TreeStore {

moveNode(to: IFileItem) {
if (this.dragNode && this.dragNode !== to && to.children!.every(c => c !== this.dropNode)) {
if (to.children?.some(c => {
return c.filename === this.dragNode!.filename && String(c.ext) === String(this.dragNode!.ext)
})) {
message$.next({
type: 'warning',
content: 'filename already exists'
})
return
}
const fromPath = this.dragNode.filePath
const toPath = to.filePath!
this.dragNode.parent!.children = this.dragNode.parent!.children!.filter(c => c !== this.dragNode)
Expand Down

0 comments on commit 9833f38

Please sign in to comment.