2937: Make sure Collection share links end with /.
authorBrett Smith <brett@curoverse.com>
Thu, 19 Jun 2014 19:14:07 +0000 (15:14 -0400)
committerBrett Smith <brett@curoverse.com>
Thu, 19 Jun 2014 19:14:07 +0000 (15:14 -0400)
This is necessary to prevent wget from saving a plain HTML file with
the name of the reader token.  With a file there, it's not possible to
make a directory tree for recursive downloads.

Closes #2937.

apps/workbench/app/controllers/collections_controller.rb
apps/workbench/app/views/collections/show_file_links.html.erb
apps/workbench/test/functional/collections_controller_test.rb

index fa83714de083b6065297304f76d982ddadbce6d9..dd85b2f741aa9b457bea29d9b573da2674806c18 100644 (file)
@@ -198,7 +198,7 @@ class CollectionsController < ApplicationController
   helper_method :download_link
 
   def download_link
-    collections_url + "/download/#{@object.uuid}/#{@search_sharing.first.api_token}"
+    collections_url + "/download/#{@object.uuid}/#{@search_sharing.first.api_token}/"
   end
 
   def share
index 78d75b1f7949f871409057ca883afa3982d2a7f8..22baaa87836601f341fc6a792dd5b001e621b1c1 100644 (file)
@@ -38,7 +38,8 @@ Arvados.  You can download individual files listed below.  To download
 the entire collection with wget, try:</p>
 
 <pre>$ wget --mirror --no-parent --no-host --cut-dirs=3 <%=
-         url_for(link_opts.merge(action: 'show_file_links', only_path: false))
+         url_for(link_opts.merge(action: 'show_file_links', only_path: false,
+                                 trailing_slash: true))
        %></pre>
 
 <h2>File Listing</h2>
index fb80f8874ec0346d735e2c0c31b400fc04696423..babe4fbf931542b7dc0c46d79afbb6874b8d198e 100644 (file)
@@ -98,6 +98,14 @@ class CollectionsControllerTest < ActionController::TestCase
     assert_no_session
   end
 
+  test "reader token Collection links end with trailing slash" do
+    # Testing the fix for #2937.
+    show_collection(:foo_file, :active_trustedclient)
+    post(:share, collection_params(:foo_file))
+    assert(@controller.download_link.ends_with? '/',
+           "Collection share link does not end with slash for wget")
+  end
+
   test "getting a file from Keep" do
     params = collection_params(:foo_file, 'foo')
     sess = session_for(:active)