fix: 重命名文件前校验是否存在冲突 (#9488)

Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
pull/9493/head
fit2bot 2023-02-09 20:05:26 +08:00 committed by GitHub
parent e36a64ae2c
commit 1b1ae1145c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -146,6 +146,8 @@ class PlaybookFileBrowserAPIView(APIView):
if new_name:
new_file_path = os.path.join(os.path.dirname(file_path), new_name)
if os.path.exists(new_file_path):
return Response({'msg': '{} already exists'.format(new_name)}, status=400)
os.rename(file_path, new_file_path)
file_path = new_file_path