[cache_restore] --debug-override-metadata-version wasn't working

This commit is contained in:
Joe Thornber 2017-03-01 10:36:34 -05:00
parent d52e934ce2
commit ba8d5ab5e4

View File

@ -60,6 +60,11 @@ namespace {
unsigned override_version; unsigned override_version;
}; };
void override_version(metadata::ptr md, flags const &fs) {
md->sb_.version = fs.override_version;
md->commit(fs.clean_shutdown);
}
int restore(flags const &fs) { int restore(flags const &fs) {
try { try {
block_manager<>::ptr bm = open_bm(*fs.output, block_manager<>::READ_WRITE); block_manager<>::ptr bm = open_bm(*fs.output, block_manager<>::READ_WRITE);
@ -67,17 +72,15 @@ namespace {
emitter::ptr restorer = create_restore_emitter(md, fs.clean_shutdown, emitter::ptr restorer = create_restore_emitter(md, fs.clean_shutdown,
fs.metadata_version); fs.metadata_version);
if (fs.override_metadata_version) {
cerr << "overriding" << endl;
md->sb_.version = fs.override_version;
}
check_file_exists(*fs.input); check_file_exists(*fs.input);
ifstream in(fs.input->c_str(), ifstream::in); ifstream in(fs.input->c_str(), ifstream::in);
unique_ptr<progress_monitor> monitor = create_monitor(fs.quiet); unique_ptr<progress_monitor> monitor = create_monitor(fs.quiet);
parse_xml(in, restorer, get_file_length(*fs.input), *monitor); parse_xml(in, restorer, get_file_length(*fs.input), *monitor);
if (fs.override_metadata_version)
override_version(md, fs);
} catch (std::exception &e) { } catch (std::exception &e) {
cerr << e.what() << endl; cerr << e.what() << endl;
return 1; return 1;