From 6fdd101abd6f1685401cb90803d3abdbebc0d9f5 Mon Sep 17 00:00:00 2001 From: Lazlo Westerhof Date: Wed, 4 Oct 2023 16:43:22 +0200 Subject: [PATCH] YDA-5439: check if collection exists in destination before copy / move --- research.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/research.py b/research.py index 2f7b8e48b..299696dbf 100644 --- a/research.py +++ b/research.py @@ -138,6 +138,10 @@ def api_research_folder_copy(ctx, folder_path, new_folder_path): if not collection.exists(ctx, folder_path): return api.Error('invalid_source', 'The original folder ' + folder_path + ' can not be found') + # Collection exists in destination? + if collection.exists(ctx, new_folder_path): + return api.Error('invalid_destination', 'Folder with this name already exists in destination. Please choose another destination') + # All requirements OK try: collection.copy(ctx, folder_path, new_folder_path) @@ -195,6 +199,10 @@ def api_research_folder_move(ctx, folder_path, new_folder_path): if not collection.exists(ctx, folder_path): return api.Error('invalid_source', 'The original folder ' + folder_path + ' can not be found') + # Collection exists in destination? + if collection.exists(ctx, new_folder_path): + return api.Error('invalid_destination', 'Folder with this name already exists in destination. Please choose another destination') + # All requirements OK try: collection.move(ctx, folder_path, new_folder_path)