Browse Source

- added check if some files in payload missed a checksum

master
parent
commit
781115968f
1 changed files with 37 additions and 1 deletions
  1. +37
    -1
      src/lib/validate_bag.cpp

+ 37
- 1
src/lib/validate_bag.cpp View File

@ -1,6 +1,6 @@
#include "bag.hpp"
#include <iostream>
bool Bag::validate( list<string> & log ) {
@ -35,6 +35,42 @@ bool Bag::validate( list<string> & log ) {
if (ret == false) {
is_valid = false;
}
if (NULL != this->payload_p) {
// check if payload checksums missed for payload files
// HINT: not requested by draft, therefore only a warning
list<string> payload_files = this->payload_p->get_all_relative_paths();
list<string> payload_manifest_files = this->payloadmanifest_p->get_checksummed_files();
list<string> missed_files;
payload_files.sort();
payload_manifest_files.sort();
//cout << "PAYLOAD_FILES:" << endl;
//auto it = payload_files.begin();
//while( it != payload_files.end()) {
// cout << "\t"<<(*it++) << endl;
//}
//cout << "PAYLOADMANIFEST_FILES:" << endl;
//it = payload_manifest_files.begin();
//while( it != payload_manifest_files.end()) {
// cout << "\t"<<(*it++) << endl;
//}
auto it1 = payload_files.begin();
auto it2 = payload_manifest_files.begin();
while( it1 != payload_files.end() && it2 != payload_manifest_files.end() ) {
int cmp_res = (*it1).compare( *it2);
//cout << "COMP: "<<cmp_res<<" file='"<< (*it1) << "' checksummed file='" << (*it2) << "'" << endl;
if ( cmp_res < 0) {
log.push_back("Bagit warning, file '" + (*it1) + "' in payload has no checksum entry in payload manifest");
it1++;
} else if ( cmp_res > 0) {
it2++;
} else {
it1++;
it2++;
}
}
}
}
// next elements are optional
if (NULL == this->tagmanifest_p) {


Loading…
Cancel
Save