Browse Source

- minor cleanups

master
Andreas Romeyke 2 months ago
parent
commit
79307541b4
8 changed files with 19 additions and 19 deletions
  1. +1
    -1
      src/include/bagmetadata.hpp
  2. +1
    -1
      src/include/othertags.hpp
  3. +4
    -0
      src/lib/bag.cpp
  4. +3
    -3
      src/lib/bagmetadata.cpp
  5. +2
    -3
      src/lib/fetchfile.cpp
  6. +4
    -4
      src/lib/manifest.cpp
  7. +4
    -5
      test/test_tagmanifest.cpp
  8. +0
    -2
      test/testbag.cpp

+ 1
- 1
src/include/bagmetadata.hpp View File

@@ -45,7 +45,7 @@ class Bagmetadata{
stringstream log;

public:
Bagmetadata( string basedir );
explicit Bagmetadata( string basedir );

string get_SourceOrganization();
string get_OrganizationAddress();


+ 1
- 1
src/include/othertags.hpp View File

@@ -23,7 +23,7 @@ class Othertags{
stringstream log;
public:
Othertags( string basedir);
bool store( string basedir);
static bool store( string basedir);
bool set_other_tag_files( list<string> &);
list<string> get_other_tag_files();
void get_logstream( stringstream & log);


+ 4
- 0
src/lib/bag.cpp View File

@@ -27,6 +27,10 @@ using namespace std;


Bag::Bag( string dfname ) {

if ('/' != dfname.back()) {
dfname += "/";
}
// log << "load constructor (" << dfname << ")" << endl;
// read in file bagit.txt
string bagit_txt_path = dfname + "bagit.txt";


+ 3
- 3
src/lib/bagmetadata.cpp View File

@@ -131,8 +131,8 @@ oxum_t Bagmetadata::get_PayloadOxum() {
string sstreams;
getline(oxumstring, soctets, '.');
getline(oxumstring, sstreams, '.');
oxum.octetcount = stoi( soctets );
oxum.streamcount = stoi( sstreams );
oxum.octetcount = stoul( soctets );
oxum.streamcount = stoul( sstreams );
}
return oxum;
}
@@ -376,7 +376,7 @@ void Bagmetadata::set_BagSize(string BagSize) {

void Bagmetadata::set_BagSize( unsigned long long int bytes) {

if (bytes > (const unsigned long long int) (1024ull*1024ull*1024ull*1024ull) ) {
if (bytes > 1024ull * 1024ull * 1024ull * 1024ull) {
this->metadata["BagSize"] = to_string (bytes/ (1024ull*1024ull*1024ull*1024ull)) + " TB";
} else if (bytes > (1024ull *1024ull*1024ull) ) {
this->metadata["BagSize"] = to_string (bytes/ (1024ull*1024ull*1024ull)) + " GB";


+ 2
- 3
src/lib/fetchfile.cpp View File

@@ -58,7 +58,7 @@ Fetchfile::Fetchfile( string basedir ) {
line_ss >> subfile;
fetch_t entry;
entry.url = url;
entry.size = stoi( length );
entry.size = stoul( length );
entry.filename = subfile;
this->entries.push_back( entry );
}
@@ -71,7 +71,6 @@ Fetchfile::Fetchfile( string basedir ) {

bool Fetchfile::fetch( fetch_t fetch ) {
CURL *curl;
CURLcode result;
curl = curl_easy_init();
if (curl != nullptr) {
FILE *fp;
@@ -81,7 +80,7 @@ bool Fetchfile::fetch( fetch_t fetch ) {
// see https://curl.haxx.se/libcurl/c/CURLOPT_WRITEFUNCTION.html#DESCRIPTION
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, fp);
result = curl_easy_perform(curl);
CURLcode result = curl_easy_perform(curl);
curl_easy_cleanup(curl);
fclose(fp);
} else {


+ 4
- 4
src/lib/manifest.cpp View File

@@ -89,8 +89,8 @@ bool Manifest::validate() {
for (auto & manifest_algorithm_file : this->manifest_algorithm_files) {
string manifest_file = manifest_algorithm_file.second;
checksum_algorithms alg = manifest_algorithm_file.first;
fs::path p{ manifest_file };
if (fs::is_regular_file( p )) {
fs::path manifest_path{manifest_file };
if (fs::is_regular_file(manifest_path )) {
at_least_one_manifest=true;
}

@@ -108,9 +108,9 @@ bool Manifest::validate() {
this->log << "Bagit file '" << file << "', checksum '" << expected_checksum << "' is expected by file '" << manifest_file << "', but found: '" << calc_checksum << "'" << endl;
is_valid = false;
}
fs::path p{ file };
fs::path file_path{file };
// fs::file_status s = fs::status( p );
if (! fs::is_regular_file( p )) {
if (! fs::is_regular_file(file_path )) {
this->log << "Bagit file '" << file << "' does not exists in '" << this->basedir << "'" << endl;
}
}


+ 4
- 5
test/test_tagmanifest.cpp View File

@@ -33,14 +33,13 @@ bool check_get_checksum_file_pairs() {
{"eaa2c609ff6371712f623f5531945b44", "bagit.txt"},
};
multimap<string,string>::iterator i;
multimap<string,string>::iterator j;
bool is_valid = true;
for (i=expected.begin(); i!=expected.end() ; i++) {
cout << "Expected: (" << (i->first) << "," << (i->second) << ")" << endl;
auto j = results.find( i->first );
if (j != results.end()) { // file found
if (j->first != i->first) {
cout << "Results: (" << (j->first) << "," << (j->second) << ")" << endl;
auto idx_first_match = results.find(i->first );
if (idx_first_match != results.end()) { // file found
if (idx_first_match->first != i->first) {
cout << "Results: (" << (idx_first_match->first) << "," << (idx_first_match->second) << ")" << endl;
is_valid=false; break;
}
} else {


+ 0
- 2
test/testbag.cpp View File

@@ -169,8 +169,6 @@ BOOST_AUTO_TEST_CASE(check_invalid_dirs) {
check_invalid_dirs();
}



BOOST_FIXTURE_TEST_CASE(check_store_ok, TARGETFIXTURE) {
BOOST_TEST(check_store("../testbags/bag_minimal_ok/", targetdir));
};


Loading…
Cancel
Save