Browse Source

- added return to store()

- check null ptr for payload in validate()
master
Andreas Romeyke 3 years ago
parent
commit
29685e2636
1 changed files with 14 additions and 10 deletions
  1. +14
    -10
      src/lib/bag.cpp

+ 14
- 10
src/lib/bag.cpp View File

@ -152,7 +152,9 @@ bool Bag::store( string basedir ) {
bagit_txt_file.close();
} else {
Bag::log << "file " << bagit_txt_path << "could not be open for writing" << endl;
return false;
}
return true;
}
@ -243,16 +245,18 @@ bool Bag::validate() {
if (this->bagmetadata_p->has_oxum()) {
// check oxum of payload
Checksum c;
list<string> files = this->payload_p->get_all_absolute_paths();
oxum_t expected_oxum = this->bagmetadata_p->get_oxum();
oxum_t calculated_oxum = c.oxum_of_filelist( files );
if (expected_oxum.octetcount != calculated_oxum.octetcount) {
this->log << "Bagit payload oxum octectcount=" << to_string(expected_oxum.octetcount) << " expected, but " << to_string(calculated_oxum.octetcount) << " found" << endl;
is_valid = false;
}
if (expected_oxum.streamcount != calculated_oxum.streamcount) {
this->log << "Bagit payload oxum streamcount=" << to_string(expected_oxum.streamcount) << " expected, but " << to_string(calculated_oxum.streamcount) << " found" << endl;
is_valid = false;
if (this->payload_p != nullptr) {
list<string> files = this->payload_p->get_all_absolute_paths();
oxum_t expected_oxum = this->bagmetadata_p->get_oxum();
oxum_t calculated_oxum = c.oxum_of_filelist( files );
if (expected_oxum.octetcount != calculated_oxum.octetcount) {
this->log << "Bagit payload oxum octectcount=" << to_string(expected_oxum.octetcount) << " expected, but " << to_string(calculated_oxum.octetcount) << " found" << endl;
is_valid = false;
}
if (expected_oxum.streamcount != calculated_oxum.streamcount) {
this->log << "Bagit payload oxum streamcount=" << to_string(expected_oxum.streamcount) << " expected, but " << to_string(calculated_oxum.streamcount) << " found" << endl;
is_valid = false;
}
}
}


Loading…
Cancel
Save