git.99rst.org
/
flatnotes.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
| inline |
side by side
(parent:
8638557
)
Fix renaming notes silently overwrites existing notes
author
Michael Kenneth S. David
<redacted>
Sat, 11 May 2024 07:10:59 +0000
(15:10 +0800)
committer
Michael Kenneth S. David
<redacted>
Sat, 11 May 2024 07:31:17 +0000
(15:31 +0800)
server/notes/file_system/file_system.py
patch
|
blob
|
history
diff --git
a/server/notes/file_system/file_system.py
b/server/notes/file_system/file_system.py
index 7c39855f34be43d2ca54abd8322ae0e1a0e5a49e..386e0fc842577898b3c28882186b9ce05a020d12 100644
(file)
--- a/
server/notes/file_system/file_system.py
+++ b/
server/notes/file_system/file_system.py
@@
-80,6
+80,10
@@
class FileSystemNotes(BaseNotes):
filepath = self._path_from_title(title)
if data.new_title is not None:
new_filepath = self._path_from_title(data.new_title)
+ if filepath != new_filepath and os.path.isfile(new_filepath):
+ raise FileExistsError(
+ f"Failed to rename. '{data.new_title}' already exists."
+ )
os.rename(filepath, new_filepath)
title = data.new_title
filepath = new_filepath
git clone https://git.99rst.org/PROJECT