MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / incr_deserialise_database

Function incr_deserialise_database

tools/comdb2ar/increment.cpp:378–544  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

376}
377
378void incr_deserialise_database(
379 const std::string& lrldestdir,
380 const std::string& datadestdir,
381 const std::string& dbname,
382 std::set<std::string>& table_set,
383 std::string& sha_fingerprint,
384 unsigned percent_full,
385 bool force_mode,
386 std::vector<std::string>& options,
387 bool& is_disk_full,
388 bool& dryrun
389)
390// Read from STDIN to deserialise an incremental backup
391{
392 static const char zero_head[512] = {0};
393
394 bool manifest_read = false;
395 bool done_with_incr = true;
396
397 std::map<std::string, FileInfo> new_files;
398 std::map<std::string, std::pair<FileInfo, std::vector<uint32_t> > > updated_files;
399 std::set<std::string> deleted_files;
400 std::vector<std::string> file_order;
401
402 while(true) {
403
404 // Read the tar block header
405 tar_block_header head;
406 size_t bytes_read = readall(0, head.c, sizeof(head.c));
407 if(bytes_read == 0){
408 // Lazy check that all increments are done (ie STDIN has no additional input)
409 break;
410 } else if(bytes_read != sizeof(head.c)) {
411
412 // Failed to read a full block header
413 std::ostringstream ss;
414 ss << "Error reading tar block header: "
415 << errno << " " << strerror(errno);
416 throw Error(ss);
417 }
418
419 // If the block is entirely blank then we're done with the increment
420 if(std::memcmp(head.c, zero_head, 512) == 0) {
421 if(!done_with_incr){
422 std::clog << "done with increment" << std::endl << std::endl;
423 done_with_incr = true;
424 new_files.clear();
425 updated_files.clear();
426 deleted_files.clear();
427 file_order.clear();
428 }
429 continue;
430 }
431
432 done_with_incr = false;
433
434 // Get the file name
435 if(head.h.filename[sizeof(head.h.filename) - 1] != '\0') {

Callers 1

deserialise_databaseFunction · 0.85

Calls 12

readallFunction · 0.85
ErrorClass · 0.85
read_octal_ullFunction · 0.85
read_serialised_sha_fileFunction · 0.85
recognize_data_fileFunction · 0.85
clear_log_folderFunction · 0.85
read_incr_manifestFunction · 0.85
process_incr_manifestFunction · 0.85
unpack_incr_dataFunction · 0.85
unpack_full_fileFunction · 0.85
handle_deleted_filesFunction · 0.85
clearMethod · 0.80

Tested by

no test coverage detected