From f63d6aab6eed0c400c3ef1477d3d414d71effd0e Mon Sep 17 00:00:00 2001 From: lian Date: Thu, 5 Mar 2015 15:24:47 +0800 Subject: [PATCH] [web-api] Check if dir existes before copy file --- seahub/api2/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/seahub/api2/views.py b/seahub/api2/views.py index 82b673b87c..ca62482cbd 100644 --- a/seahub/api2/views.py +++ b/seahub/api2/views.py @@ -1140,6 +1140,10 @@ class OpCopyView(APIView): return api_error(status.HTTP_400_BAD_REQUEST, 'Missing argument.') + if seafile_api.get_dir_id_by_path(repo_id, parent_dir) is None or \ + seafile_api.get_dir_id_by_path(repo_id, dst_dir) is None: + return api_error(status.HTTP_400_BAD_REQUEST, 'Path does not exist.') + parent_dir_utf8 = parent_dir.encode('utf-8') for file_name in file_names.split(':'): file_name = unquote(file_name.encode('utf-8'))