Skip to content

Commit

Permalink
YDA-5439: check if collection exists in destination before copy / move
Browse files Browse the repository at this point in the history
  • Loading branch information
lwesterhof committed Oct 4, 2023
1 parent f3f164a commit 84723c7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions research.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 84723c7

Please sign in to comment.