[ARVADOS] created: 2449ae26b0d8be41aa5411e62032c9fb1ea9af71

git at public.curoverse.com git at public.curoverse.com
Thu Sep 4 14:08:45 EDT 2014


        at  2449ae26b0d8be41aa5411e62032c9fb1ea9af71 (commit)


commit 2449ae26b0d8be41aa5411e62032c9fb1ea9af71
Author: radhika <radhika at curoverse.com>
Date:   Thu Sep 4 14:06:34 2014 -0400

    3710: update the combine_selected_files_into_collection method to also handle the scenarios where a collection uuid or "collection uuid/filename" is passed.

diff --git a/apps/workbench/app/controllers/actions_controller.rb b/apps/workbench/app/controllers/actions_controller.rb
index fcca2ab..ec71acc 100644
--- a/apps/workbench/app/controllers/actions_controller.rb
+++ b/apps/workbench/app/controllers/actions_controller.rb
@@ -116,17 +116,24 @@ class ActionsController < ApplicationController
     files = []
     params["selection"].each do |s|
       a = ArvadosBase::resource_class_for_uuid s
+      uuid_with_optional_file = false
       m = nil
       if a == Link
         begin
           m = CollectionsHelper.match(Link.find(s).head_uuid)
         rescue
         end
+      elsif (m = CollectionsHelper.match(s))
+        m
       else
-        m = CollectionsHelper.match(s)
+        m = CollectionsHelper.match_uuid_with_optional_filepath(s)
+        uuid_with_optional_file = true
       end
 
-      if m and m[1] and m[2]
+      if uuid_with_optional_file
+        lst.append(m[1])
+        files.append(m)
+      elsif m and m[1] and m[2]
         lst.append(m[1] + m[2])
         files.append(m)
       end
@@ -142,11 +149,20 @@ class ActionsController < ApplicationController
 
     combined = ""
     files.each do |m|
-      mt = chash[m[1]+m[2]].manifest_text
-      if m[4]
-        combined += arv_normalize mt, '--extract', m[4][1..-1]
+      if CollectionsHelper.match_uuid_with_optional_filepath(m[0])
+        mt = chash[m[1]].manifest_text
+        if m[2].andand.size>0
+          combined += arv_normalize mt, '--extract', m[2][1..-1]
+        else
+          combined += chash[m[1]].manifest_text
+        end
       else
-        combined += chash[m[1]+m[2]].manifest_text
+        mt = chash[m[1]+m[2]].manifest_text
+        if m[4]
+          combined += arv_normalize mt, '--extract', m[4][1..-1]
+        else
+          combined += chash[m[1]+m[2]].manifest_text
+        end
       end
     end
 
diff --git a/apps/workbench/app/helpers/collections_helper.rb b/apps/workbench/app/helpers/collections_helper.rb
index 23933cf..c1ceb8b 100644
--- a/apps/workbench/app/helpers/collections_helper.rb
+++ b/apps/workbench/app/helpers/collections_helper.rb
@@ -18,6 +18,15 @@ module CollectionsHelper
   end
 
   ##
+  # Regex match for collection UUID or "UUID/file" path.
+  # Returns a regex match object with the
+  # UUID in group 1, (optional) file path in group 2; or nil for no match.
+  #
+  def self.match_uuid_with_optional_filepath(uuid_with_optional_file)
+    /^([0-9a-z]{5}-[0-9a-z]{5}-[0-9a-z]{15})(\/*.*)$/.match(uuid_with_optional_file.to_s)
+  end
+
+  ##
   # Regex match for common image file extensions, returns a regex match object
   # with the matched extension in group 1; or nil for no match.
   #

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list