(parse_ledger_data): Set journal->price_db if a price database is
successfully read in.
This commit is contained in:
parent
d62f9bb9bf
commit
d6475fc4a2
1 changed files with 13 additions and 8 deletions
21
config.cc
21
config.cc
|
|
@ -269,10 +269,14 @@ void parse_ledger_data(journal_t * journal, parser_t * cache_parser,
|
||||||
if (access(config.cache_file.c_str(), R_OK) != -1) {
|
if (access(config.cache_file.c_str(), R_OK) != -1) {
|
||||||
std::ifstream stream(config.cache_file.c_str());
|
std::ifstream stream(config.cache_file.c_str());
|
||||||
if (cache_parser->test(stream)) {
|
if (cache_parser->test(stream)) {
|
||||||
|
std::string price_db_orig = journal->price_db;
|
||||||
|
journal->price_db = config.price_db;
|
||||||
entry_count += cache_parser->parse(stream, journal, NULL,
|
entry_count += cache_parser->parse(stream, journal, NULL,
|
||||||
&config.data_file);
|
&config.data_file);
|
||||||
if (entry_count > 0)
|
if (entry_count > 0)
|
||||||
config.cache_dirty = false;
|
config.cache_dirty = false;
|
||||||
|
else
|
||||||
|
journal->price_db = price_db_orig;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -300,13 +304,14 @@ void parse_ledger_data(journal_t * journal, parser_t * cache_parser,
|
||||||
parse_conversion("1.00 Gb", "1024 Mb");
|
parse_conversion("1.00 Gb", "1024 Mb");
|
||||||
parse_conversion("1.00 Tb", "1024 Gb");
|
parse_conversion("1.00 Tb", "1024 Gb");
|
||||||
|
|
||||||
std::string price_db;
|
journal->price_db = config.price_db;
|
||||||
if (! config.price_db.empty() &&
|
if (! journal->price_db.empty() &&
|
||||||
access(config.price_db.c_str(), R_OK) != -1) {
|
access(journal->price_db.c_str(), R_OK) != -1) {
|
||||||
if (parse_journal_file(config.price_db, journal))
|
if (parse_journal_file(journal->price_db, journal)) {
|
||||||
throw error("Entries not allowed in price history file");
|
throw error("Entries not allowed in price history file");
|
||||||
else {
|
} else {
|
||||||
price_db = config.price_db;
|
DEBUG_PRINT("ledger.config.cache",
|
||||||
|
"read price database " << journal->price_db);
|
||||||
journal->sources.pop_back();
|
journal->sources.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -323,8 +328,8 @@ void parse_ledger_data(journal_t * journal, parser_t * cache_parser,
|
||||||
}
|
}
|
||||||
else if (access(config.data_file.c_str(), R_OK) != -1) {
|
else if (access(config.data_file.c_str(), R_OK) != -1) {
|
||||||
entry_count += parse_journal_file(config.data_file, journal, account);
|
entry_count += parse_journal_file(config.data_file, journal, account);
|
||||||
if (! price_db.empty())
|
if (! journal->price_db.empty())
|
||||||
journal->sources.push_back(price_db);
|
journal->sources.push_back(journal->price_db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue