浏览代码

HUE-4399 [fb] Renaming a key (non-bucket directory) creates an extraneous empty file

Jenny Kim 9 年之前
父节点
当前提交
f82c28027f
共有 2 个文件被更改,包括 4 次插入0 次删除
  1. 2 0
      apps/filebrowser/src/filebrowser/views.py
  2. 2 0
      desktop/libs/aws/src/aws/s3/s3fs.py

+ 2 - 0
apps/filebrowser/src/filebrowser/views.py

@@ -1026,6 +1026,8 @@ def rename(request):
         if "/" not in dest_path:
             src_dir = os.path.dirname(src_path)
             dest_path = request.fs.join(src_dir, dest_path)
+        if request.fs.exists(dest_path):
+          raise PopupException(_('The destination path "%s" already exists.') % dest_path)
         request.fs.rename(src_path, dest_path)
 
     return generic_op(RenameForm, request, smart_rename, ["src_path", "dest_path"], None)

+ 2 - 0
desktop/libs/aws/src/aws/s3/s3fs.py

@@ -318,6 +318,8 @@ class S3FileSystem(object):
   def rename(self, old, new):
     new = s3.abspath(old, new)
     self.copy(old, new, recursive=True)
+    if self.isdir(old):
+      self.rename_star(old, new)
     self.rmtree(old, skipTrash=True)
 
   @translate_s3_error