| 376 | } |
| 377 | |
| 378 | void 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') { |
no test coverage detected