Skip to content

Commit

Permalink
deposit-bag-validator: small tweaks for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
ndushay committed Mar 20, 2018
1 parent 3864176 commit 088b957
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/moab/deposit_bag_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def bag_dir_exists?
deposit_bag_pathname.exist?
end

# assumes this is called when result_array is empty, as subsequent checks will use these required files
def required_bag_files_exist?
REQUIRED_BAG_FILES.each do |filename|
pathname = deposit_bag_pathname.join(filename)
Expand All @@ -90,15 +91,15 @@ def required_bag_files_exist?
def verify_version
version_md_pathname = deposit_bag_pathname.join(VERSION_METADATA_PATH)
version_from_file = last_version_id_from_version_md_xml(version_md_pathname)
verify_version_in_xml_file(version_md_pathname, version_from_file) if version_from_file
verify_version_from_xml_file(version_md_pathname, version_from_file) if version_from_file

version_additions_pathname = deposit_bag_pathname.join(VERSION_ADDITIONS_BASENAME)
version_from_file = version_id_from_version_manifest_xml(version_additions_pathname)
verify_version_in_xml_file(version_additions_pathname, version_from_file) if version_from_file
verify_version_from_xml_file(version_additions_pathname, version_from_file) if version_from_file

version_inventory_pathname = deposit_bag_pathname.join(VERSION_INVENTORY_BASENAME)
version_from_file = version_id_from_version_manifest_xml(version_inventory_pathname)
verify_version_in_xml_file(version_inventory_pathname, version_from_file) if version_from_file
verify_version_from_xml_file(version_inventory_pathname, version_from_file) if version_from_file
end

def last_version_id_from_version_md_xml(version_md_pathname)
Expand Down Expand Up @@ -128,7 +129,7 @@ def last_version_id_from_xml(pathname, xpath)
nil
end

def verify_version_in_xml_file(file_pathname, found)
def verify_version_from_xml_file(file_pathname, found)
return if found == expected_new_version
err_data = {
file_pathname: file_pathname,
Expand Down Expand Up @@ -262,9 +263,9 @@ def verify_manifest_checksums(manifest_type, manifests_checksum_hash, generated_
def checksums_diff_hash(left_checksums, right_checksums, left_label, right_label)
diff_hash = {}
# NOTE: these are intentionally & and | instead of && and ||
matching_checksum_types = (left_checksums.keys & right_checksums.keys)
matching_checksum_types = (left_checksums.keys | right_checksums.keys) if matching_checksum_types.empty?
matching_checksum_types.each do |type|
checksum_types_to_compare = (left_checksums.keys & right_checksums.keys)
checksum_types_to_compare = (left_checksums.keys | right_checksums.keys) if checksum_types_to_compare.empty?
checksum_types_to_compare.each do |type|
left_checksum = left_checksums[type]
right_checksum = right_checksums[type]
if left_checksum != right_checksum
Expand Down

0 comments on commit 088b957

Please sign in to comment.