serialize :properties, Hash
before_validation :check_encoding
serialize :properties, Hash
before_validation :check_encoding
before_validation :check_signatures
before_validation :strip_signatures_and_update_replication_confirmed
validate :ensure_pdh_matches_manifest_text
before_validation :check_signatures
before_validation :strip_signatures_and_update_replication_confirmed
validate :ensure_pdh_matches_manifest_text
- self.manifest_text.lines.each do |entry|
- entry.split[1..-1].each do |tok|
- if tok =~ FILE_TOKEN
+ self.manifest_text.each_line do |entry|
+ entry.split.each do |tok|
+ if tok == '.' or tok.starts_with? './'
+ # Stream name token.
+ elsif tok =~ FILE_TOKEN
# This is a filename token, not a blob locator. Note that we
# keep checking tokens after this, even though manifest
# format dictates that all subsequent tokens will also be
# This is a filename token, not a blob locator. Note that we
# keep checking tokens after this, even though manifest
# format dictates that all subsequent tokens will also be
true
elsif portable_data_hash.nil? or not portable_data_hash_changed?
self.portable_data_hash = computed_pdh
true
elsif portable_data_hash.nil? or not portable_data_hash_changed?
self.portable_data_hash = computed_pdh
- elsif portable_data_hash !~ /^[0-9a-f]{32}(\+\d+)?$/
- errors.add(:portable_data_hash, "is not a valid hash or hash+size")
+ elsif portable_data_hash !~ Keep::Locator::LOCATOR_REGEXP
+ errors.add(:portable_data_hash, "is not a valid locator")
false
elsif portable_data_hash[0..31] != computed_pdh[0..31]
errors.add(:portable_data_hash,
false
elsif portable_data_hash[0..31] != computed_pdh[0..31]
errors.add(:portable_data_hash,
end
def self.each_manifest_locator manifest
# Given a manifest text and a block, yield the regexp match object
# for each locator.
manifest.each_line do |line|
end
def self.each_manifest_locator manifest
# Given a manifest text and a block, yield the regexp match object
# for each locator.
manifest.each_line do |line|
- line.rstrip!
- words = line.split(' ')
- words.each do |word|
+ # line will have a trailing newline, but the last token is never
+ # a locator, so it's harmless here.
+ line.split(' ').each do |word|