[ARVADOS] updated: deaf93e06ddfb5346f0492f99f441aa4734e6bf5
git at public.curoverse.com
git at public.curoverse.com
Thu Aug 27 11:31:36 EDT 2015
Summary of changes:
services/api/lib/salvage_collection.rb | 37 +++++++++--------------
services/api/test/unit/salvage_collection_test.rb | 25 +++++++--------
2 files changed, 25 insertions(+), 37 deletions(-)
via deaf93e06ddfb5346f0492f99f441aa4734e6bf5 (commit)
from 9259c169b6254ea581fcdcb18e1cdbe9b9fbea1e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit deaf93e06ddfb5346f0492f99f441aa4734e6bf5
Author: Tom Clegg <tom at curoverse.com>
Date: Thu Aug 27 11:31:14 2015 -0400
6859: Find locator-like strings even if not space-delimited.
diff --git a/services/api/lib/salvage_collection.rb b/services/api/lib/salvage_collection.rb
index 79a2d58..2011f81 100755
--- a/services/api/lib/salvage_collection.rb
+++ b/services/api/lib/salvage_collection.rb
@@ -23,31 +23,22 @@ module SalvageCollection
end
end
- # Get all the locators from the original manifest
- LOCATOR_REGEXP = /((.*))?([[:xdigit:]]{32})(\+(.*))?\z/
+ # Get all the locators (and perhaps other strings that look a lot
+ # like a locators) from the original manifest, even if they don't
+ # appear in the correct positions with the correct space delimiters.
def salvage_collection_locator_data manifest
- locators = []
- size = 0
- manifest.each_line do |line|
- line.split(' ').each do |word|
- if match = LOCATOR_REGEXP.match(word)
- if match.size == 6 and match[5]
- size_str = match[5].split('+')[0]
- if size_str.to_i.to_s == size_str
- word = match[3] + '+' + size_str # get rid of any other hints
- size += size_str.to_i
- else
- word = match[3]
- end
- else
- word = match[3]
- end
- locators << word
- end
- end
+ locators = []
+ size = 0
+ manifest.scan /(^|[^[:xdigit:]])([[:xdigit:]]{32})((\+\d+)(\+|\b))?/ do |_, hash, _, sizehint, _|
+ if sizehint
+ locators << hash.downcase + sizehint
+ size += sizehint.to_i
+ else
+ locators << hash.downcase
end
- locators << 'd41d8cd98f00b204e9800998ecf8427e+0' if !locators.any?
- return [locators, size]
+ end
+ locators << 'd41d8cd98f00b204e9800998ecf8427e+0' if !locators.any?
+ return [locators, size]
end
def salvage_collection uuid, reason='salvaged - see #6277, #6859'
diff --git a/services/api/test/unit/salvage_collection_test.rb b/services/api/test/unit/salvage_collection_test.rb
index 47abe5a..a269078 100644
--- a/services/api/test/unit/salvage_collection_test.rb
+++ b/services/api/test/unit/salvage_collection_test.rb
@@ -15,7 +15,7 @@ TEST_MANIFEST_STRIPPED = ". 341dabea2bd78ad0d6fc3f5b926b450e+85626 0:85626:brca2
# 341dabea2bd78ad0d6fc3f5b926b450e+abc
# 341dabea2bd78ad0d6fc3f5b926abcdf
# Expectation: All these locators are preserved in salvaged_data
-BAD_MANIFEST = "faaaafaafaafaabd78ad0d6fc3f5b926b450e+foo bar-baabaabaabd78ad0d6fc3f5b926b450e bad12345dae58ad0d6fc3f5b926b450e+ 341dabea2bd78ad0d6fc3f5b926b450e+abc 341dabea2bd78ad0d6fc3f5b926abcdf 0:85626:brca2-hg19.fa\n. abcdabea2bd78ad0d6fc3f5b926b450e+1000 0:1000:brca-hg19.fa\n. d7321a918923627c972d8f8080c07d29+2000+A22e0a1d9b9bc85c848379d98bedc64238b0b1532 at 55e076ce 0:2000:brca1-hg19.fa\n"
+BAD_MANIFEST = "faafaafaabd78ad0d6fc3f5b926b450e+foo bar-baabaabaabd78ad0d6fc3f5b926b450e_bad12345dae58ad0d6fc3f5b926b450e+ 341dabea2bd78ad0d6fc3f5b926b450e+abc 341dabea2bd78ad0d6fc3f5b926abcdf 0:85626:brca2-hg19.fa\n. abcdabea2bd78ad0d6fc3f5b926b450e+1000 0:1000:brca-hg19.fa\n. d7321a918923627c972d8f8080c07d29+2000+A22e0a1d9b9bc85c848379d98bedc64238b0b1532 at 55e076ce 0:2000:brca1-hg19.fa\n"
class SalvageCollectionTest < ActiveSupport::TestCase
include SalvageCollection
@@ -121,19 +121,16 @@ class SalvageCollectionTest < ActiveSupport::TestCase
# Expectation: All these locators are preserved in salvaged_data
test "invalid locators preserved during salvaging" do
locator_data = salvage_collection_locator_data BAD_MANIFEST
- assert_equal 7, locator_data[0].size
- assert_equal false, locator_data[0].include?("foo-faafaafaabd78ad0d6fc3f5b926b450e+foo")
- assert_equal true, locator_data[0].include?("faafaafaabd78ad0d6fc3f5b926b450e")
- assert_equal false, locator_data[0].include?("bar-baabaabaabd78ad0d6fc3f5b926b450e")
- assert_equal true, locator_data[0].include?("baabaabaabd78ad0d6fc3f5b926b450e")
- assert_equal false, locator_data[0].include?("bad12345dae58ad0d6fc3f5b926b450e+")
- assert_equal true, locator_data[0].include?("bad12345dae58ad0d6fc3f5b926b450e")
- assert_equal false, locator_data[0].include?("341dabea2bd78ad0d6fc3f5b926b450e+abc")
- assert_equal true, locator_data[0].include?("341dabea2bd78ad0d6fc3f5b926b450e")
- assert_equal true, locator_data[0].include?("341dabea2bd78ad0d6fc3f5b926abcdf")
- assert_equal true, locator_data[0].include?("abcdabea2bd78ad0d6fc3f5b926b450e+1000")
- assert_equal true, locator_data[0].include?("d7321a918923627c972d8f8080c07d29+2000")
- assert_equal true, locator_data[1].eql?(1000 + 2000) # size
+ assert_equal \
+ ["faafaafaabd78ad0d6fc3f5b926b450e",
+ "baabaabaabd78ad0d6fc3f5b926b450e",
+ "bad12345dae58ad0d6fc3f5b926b450e",
+ "341dabea2bd78ad0d6fc3f5b926b450e",
+ "341dabea2bd78ad0d6fc3f5b926abcdf",
+ "abcdabea2bd78ad0d6fc3f5b926b450e+1000",
+ "d7321a918923627c972d8f8080c07d29+2000",
+ ], locator_data[0]
+ assert_equal 1000+2000, locator_data[1]
end
test "salvage a collection with invalid manifest text" do
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list