14870: Ruby SDK fix for copying collection into root of an empty collection
[arvados.git] / sdk / ruby / lib / arvados / collection.rb
index 6cc3072b77e175c5ddc91cd930fccb6ed213b975..f236ce83a30a47e51c8e8499abb7b5aecfe29c56 100644 (file)
@@ -369,7 +369,11 @@ module Arv
       end
 
       def add_copy(src_item, key)
-        self[key] = src_item.copy_named("#{path}/#{key}")
+        if key == "."
+          self[key] = src_item.copy_named("#{path}")
+        else
+          self[key] = src_item.copy_named("#{path}/#{key}")
+        end
       end
 
       def merge(src_item, key)
@@ -457,6 +461,10 @@ module Arv
         items["."] = CollectionStream.new(".")
       end
 
+      def add_copy(src_item, key)
+        items["."].add_copy(src_item, key)
+      end
+
       def raise_root_write_error(key)
         raise ArgumentError.new("can't write to %p at collection root" % key)
       end