fixed bug renaming note will ovewrite if note has same name of existing
This commit is contained in:
parent
90048fcd22
commit
2f963edebe
|
|
@ -86,6 +86,10 @@ def move_note(notes_dir: str, old_path: str, new_path: str) -> bool:
|
|||
if not old_full_path.exists():
|
||||
return False
|
||||
|
||||
# Check if target already exists (prevent overwriting)
|
||||
if new_full_path.exists():
|
||||
return False
|
||||
|
||||
# Invalidate cache for old path
|
||||
old_key = str(old_full_path)
|
||||
if old_key in _tag_cache:
|
||||
|
|
|
|||
|
|
@ -2615,6 +2615,15 @@ function noteApp() {
|
|||
|
||||
if (oldPath === newPath) return;
|
||||
|
||||
// Check if a note with the new name already exists
|
||||
const existingNote = this.notes.find(n => n.path.toLowerCase() === newPath.toLowerCase());
|
||||
if (existingNote) {
|
||||
alert(`A note named "${newName}" already exists in this folder.`);
|
||||
// Reset the name in the UI
|
||||
this.currentNoteName = oldPath.split('/').pop().replace('.md', '');
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new note with same content
|
||||
try {
|
||||
const response = await fetch(`/api/notes/${newPath}`, {
|
||||
|
|
|
|||
Loading…
Reference in New Issue