Module: check_mk
Branch: master
Commit: 3d3fdaebbfac3f9ccbf5da491ef28ad197c00f82
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3d3fdaebbfac3f…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Aug 28 16:09:51 2015 +0200
#2550 FIX Catching exception when having name conflicts while moving a folder
---
.werks/2550 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/wato.py | 5 ++++-
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/.werks/2550 b/.werks/2550
new file mode 100644
index 0000000..536ff8a
--- /dev/null
+++ b/.werks/2550
@@ -0,0 +1,10 @@
+Title: Catching exception when having name conflicts while moving a folder
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i3
+Date: 1440770937
+
+
diff --git a/ChangeLog b/ChangeLog
index b9c9ed3..d62e895 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -205,6 +205,7 @@
* 2474 FIX: Fixed possible corruption of user datasets (contact, mail, rbn
config)...
* 2499 FIX: Git: Fixed message "Please tell me who you are. Run git config
..." on making changes...
* 2539 FIX: Fix impossibility of removing a status host from an existing site
configuration
+ * 2550 FIX: Catching exception when having name conflicts while moving a folder
Notifications:
* 2478 Integrated notification plugin for mobile phone push messages via Pushover...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index db1ac9d..ba61f43 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -1700,12 +1700,15 @@ def move_folder(what_folder, target_folder):
elif target_folder.get(".lock_subfolders"):
raise MKUserError(None, _("Cannot move folder: Target folder is
locked."))
+ new_dir = folder_dir(target_folder)
+ if os.path.exists(new_dir):
+ raise MKUserError(None, _("Cannot move folder: A folder with this name
already exists in the target folder."))
+
old_parent = what_folder[".parent"]
old_dir = folder_dir(what_folder)
del old_parent[".folders"][what_folder[".name"]]
target_folder[".folders"][what_folder[".name"]] = what_folder
what_folder[".parent"] = target_folder
- new_dir = folder_dir(target_folder)
shutil.move(old_dir, new_dir)
def delete_folder(folder):