Simplify the timestamp handling

This commit is contained in:
Patrick Niklaus 2016-03-23 16:58:47 +01:00
parent 39b3cab1da
commit 1e753e98ce
2 changed files with 7 additions and 37 deletions

View File

@ -100,26 +100,15 @@ class InternalDataFacade final : public BaseDataFacade
} }
void LoadTimestamp(const boost::filesystem::path &timestamp_path) void LoadTimestamp(const boost::filesystem::path &timestamp_path)
{
if (boost::filesystem::exists(timestamp_path))
{ {
util::SimpleLogger().Write() << "Loading Timestamp"; util::SimpleLogger().Write() << "Loading Timestamp";
boost::filesystem::ifstream timestamp_stream(timestamp_path); boost::filesystem::ifstream timestamp_stream(timestamp_path);
if (!timestamp_stream) if (!timestamp_stream)
{ {
util::SimpleLogger().Write(logWARNING) << timestamp_path << " not found"; throw util::exception("Could not open " + timestamp_path.string() + " for reading.");
} }
getline(timestamp_stream, m_timestamp); getline(timestamp_stream, m_timestamp);
} }
if (m_timestamp.empty())
{
m_timestamp = "n/a";
}
if (25 < m_timestamp.length())
{
m_timestamp.resize(25);
}
}
void LoadGraph(const boost::filesystem::path &hsgr_path) void LoadGraph(const boost::filesystem::path &hsgr_path)
{ {

View File

@ -216,28 +216,9 @@ int Storage::Run()
shared_layout_ptr->SetBlockSize<extractor::ProfileProperties>(SharedDataLayout::PROPERTIES, 1); shared_layout_ptr->SetBlockSize<extractor::ProfileProperties>(SharedDataLayout::PROPERTIES, 1);
// load timestamp size // load timestamp size
std::string m_timestamp;
if (boost::filesystem::exists(config.timestamp_path))
{
boost::filesystem::ifstream timestamp_stream(config.timestamp_path); boost::filesystem::ifstream timestamp_stream(config.timestamp_path);
if (!timestamp_stream) std::string m_timestamp;
{
util::SimpleLogger().Write(logWARNING) << config.timestamp_path
<< " not found. setting to default";
}
else
{
getline(timestamp_stream, m_timestamp); getline(timestamp_stream, m_timestamp);
}
}
if (m_timestamp.empty())
{
m_timestamp = "n/a";
}
if (25 < m_timestamp.length())
{
m_timestamp.resize(25);
}
shared_layout_ptr->SetBlockSize<char>(SharedDataLayout::TIMESTAMP, m_timestamp.length()); shared_layout_ptr->SetBlockSize<char>(SharedDataLayout::TIMESTAMP, m_timestamp.length());
// load core marker size // load core marker size