From 2f963edebe8a2951314a340dc352a03a27baca06 Mon Sep 17 00:00:00 2001 From: Gamosoft Date: Thu, 11 Dec 2025 11:00:21 +0100 Subject: [PATCH] fixed bug renaming note will ovewrite if note has same name of existing --- backend/utils.py | 4 ++++ frontend/app.js | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/backend/utils.py b/backend/utils.py index 4e8e2b4..b1eaf39 100644 --- a/backend/utils.py +++ b/backend/utils.py @@ -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: diff --git a/frontend/app.js b/frontend/app.js index 8a09198..531550a 100644 --- a/frontend/app.js +++ b/frontend/app.js @@ -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}`, {