- def self.salvage_collection_locator_data manifest
- # Get all the locators from the original manifest
- locators = []
- size = 0
- manifest.each_line do |line|
- line.split(' ').each do |word|
- if match = Keep::Locator::LOCATOR_REGEXP.match(word)
- word = match[1]+match[2] # get rid of any hints
- locators << word
- size += match[3].to_i
- end
- end
+ # 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.scan(/(^|[^[:xdigit:]])([[:xdigit:]]{32})((\+\d+)(\+|\b))?/) do |_, hash, _, sizehint, _|
+ if sizehint
+ locators << hash.downcase + sizehint
+ size += sizehint.to_i
+ else
+ locators << hash.downcase