[ARVADOS] created: 2527b9cd7958d89a5ae0dd84856027908c48ae53

git at public.curoverse.com git at public.curoverse.com
Mon Feb 9 11:20:15 EST 2015


        at  2527b9cd7958d89a5ae0dd84856027908c48ae53 (commit)


commit 2527b9cd7958d89a5ae0dd84856027908c48ae53
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Feb 9 11:20:28 2015 -0500

    5176: Add spaces-in-filenames tests.

diff --git a/apps/workbench/Gemfile b/apps/workbench/Gemfile
index b24cb26..c120783 100644
--- a/apps/workbench/Gemfile
+++ b/apps/workbench/Gemfile
@@ -1,7 +1,7 @@
 source 'https://rubygems.org'
 
 gem 'rails', '~> 4.1.0'
-gem 'arvados', '>= 0.1.20150116063758'
+gem 'arvados', '>= 0.1.20150209154913'
 
 gem 'sqlite3'
 
diff --git a/apps/workbench/Gemfile.lock b/apps/workbench/Gemfile.lock
index 1833a08..9380e3c 100644
--- a/apps/workbench/Gemfile.lock
+++ b/apps/workbench/Gemfile.lock
@@ -40,7 +40,7 @@ GEM
     andand (1.3.3)
     angularjs-rails (1.3.8)
     arel (5.0.1.20140414130214)
-    arvados (0.1.20150116063758)
+    arvados (0.1.20150209154913)
       activesupport (>= 3.2.13)
       andand (~> 1.3, >= 1.3.3)
       google-api-client (~> 0.6.3, >= 0.6.3)
@@ -258,7 +258,7 @@ DEPENDENCIES
   RedCloth
   andand
   angularjs-rails
-  arvados (>= 0.1.20150116063758)
+  arvados (>= 0.1.20150209154913)
   bootstrap-sass (~> 3.1.0)
   bootstrap-tab-history-rails
   bootstrap-x-editable-rails
diff --git a/apps/workbench/test/controllers/collections_controller_test.rb b/apps/workbench/test/controllers/collections_controller_test.rb
index 95c0a57..ca5763b 100644
--- a/apps/workbench/test/controllers/collections_controller_test.rb
+++ b/apps/workbench/test/controllers/collections_controller_test.rb
@@ -56,6 +56,25 @@ class CollectionsControllerTest < ActionController::TestCase
     assert_equal([['.', 'foo', 3]], assigns(:object).files)
   end
 
+  test "viewing a collection with spaces in filename" do
+    show_collection(:w_a_z_file, :active)
+    assert_equal([['.', 'w a z', 5]], assigns(:object).files)
+  end
+
+  test "download a file with spaces in filename" do
+    collection = api_fixture('collections')['w_a_z_file']
+    fakepipe = IO.popen(['echo', '-n', 'w a z'], 'rb')
+    IO.expects(:popen).with { |cmd, mode|
+      cmd.include? "#{collection['uuid']}/w a z"
+    }.returns(fakepipe)
+    get :show_file, {
+      uuid: collection['uuid'],
+      file: 'w a z'
+    }, session_for(:active)
+    assert_response :success
+    assert_equal 'w a z', response.body
+  end
+
   test "viewing a collection fetches related projects" do
     show_collection({id: api_fixture('collections')["foo_file"]['portable_data_hash']}, :active)
     assert_includes(assigns(:same_pdh).map(&:owner_uuid),
diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml
index f28606a..8419178 100644
--- a/services/api/test/fixtures/collections.yml
+++ b/services/api/test/fixtures/collections.yml
@@ -58,6 +58,18 @@ baz_file:
   manifest_text: ". 73feffa4b7f6bb68e44cf984c85f6e88+3 0:3:baz\n"
   name: baz_file
 
+w_a_z_file:
+  uuid: zzzzz-4zz18-25k12570yk134b3
+  portable_data_hash: 8706aadd12a0ebc07d74cae88762ba9e
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  created_at: 2015-02-09T10:53:38Z
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
+  modified_at: 2015-02-09T10:53:38Z
+  updated_at: 2015-02-09T10:53:38Z
+  manifest_text: ". 4c6c2c0ac8aa0696edd7316a3be5ca3c+5 0:5:w\\040\\141\\040z\n"
+  name: "\"w a z\" file"
+
 multilevel_collection_1:
   uuid: zzzzz-4zz18-pyw8yp9g3pr7irn
   portable_data_hash: 1fd08fc162a5c6413070a8bd0bffc818+150

commit dd645c9e973b9b725f310513ce309fa1e1a82421
Author: Tom Clegg <tom at curoverse.com>
Date:   Mon Feb 9 10:49:13 2015 -0500

    5176: Fix handling of escape sequences in manifest filenames.

diff --git a/sdk/ruby/lib/arvados/keep.rb b/sdk/ruby/lib/arvados/keep.rb
index f28cfdc..25a6ae1 100644
--- a/sdk/ruby/lib/arvados/keep.rb
+++ b/sdk/ruby/lib/arvados/keep.rb
@@ -138,7 +138,7 @@ module Keep
 
     def split_file_token token
       start_pos, filesize, filename = token.split(':', 3)
-      [start_pos.to_i, filesize.to_i, filename]
+      [start_pos.to_i, filesize.to_i, unescape(filename)]
     end
 
     def each_file_spec
diff --git a/sdk/ruby/test/test_keep_manifest.rb b/sdk/ruby/test/test_keep_manifest.rb
index 64c8ea3..39ce868 100644
--- a/sdk/ruby/test/test_keep_manifest.rb
+++ b/sdk/ruby/test/test_keep_manifest.rb
@@ -105,6 +105,11 @@ class ManifestTest < Minitest::Test
     assert_equal([[".", "file:test.txt", 9]], manifest.files)
   end
 
+  def test_files_with_escape_sequence_in_filename
+    manifest = Keep::Manifest.new(". #{random_block(9)} 0:9:a\\040\\141.txt\n")
+    assert_equal([[".", "a a.txt", 9]], manifest.files)
+  end
+
   def test_files_spanning_multiple_blocks
     manifest = Keep::Manifest.new(MULTIBLOCK_FILE_MANIFEST)
     assert_equal([[".", "repfile", 5],
@@ -153,4 +158,12 @@ class ManifestTest < Minitest::Test
     refute(manifest.has_file?("./s2/repfile"), "one-arg missing stream found")
     refute(manifest.has_file?("./s2", "repfile"), "two-arg missing stream found")
   end
+
+  def test_has_file_with_spaces
+    manifest = Keep::Manifest.new(". #{random_block(3)} 0:3:a\\040b\\040c\n")
+    assert(manifest.has_file?("./a b c"), "one-arg 'a b c' not found")
+    assert(manifest.has_file?(".", "a b c"), "two-arg 'a b c' not found")
+    refute(manifest.has_file?("a\\040b\\040c"), "one-arg unescaped found")
+    refute(manifest.has_file?(".", "a\\040b\\040c"), "two-arg unescaped found")
+  end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list