11185: Addressed several requests:
[arvados.git] / apps / workbench / app / controllers / collections_controller.rb
index bac3f8eae59b2c80b224666f01f46dc06860ea20..dc9ed43c409b64a2838ad74d3e165609c49e1e62 100644 (file)
@@ -326,15 +326,21 @@ class CollectionsController < ApplicationController
       end
 
       arv_coll = Arv::Collection.new(@object.manifest_text)
-      arv_coll.rename "./"+file_path, new_file_path
 
-      if @object.update_attributes manifest_text: arv_coll.manifest_text
-        show
-      else
+      if arv_coll.exist?(new_file_path)
+        @errors = 'Duplicate file path. Please use a different name.'
         self.render_error status: 422
+      else
+        arv_coll.rename "./"+file_path, new_file_path
+
+        if @object.update_attributes manifest_text: arv_coll.manifest_text
+          show
+        else
+          self.render_error status: 422
+        end
       end
     else
-      # Non a file rename; use default
+      # Not a file rename; use default
       super
     end
   end