From 2b0a1bbb63fb9eaa578584f4493b50f403ac41f7 Mon Sep 17 00:00:00 2001 From: Patrick Niklaus Date: Wed, 23 Mar 2016 16:58:47 +0100 Subject: [PATCH] Simplify the timestamp handling --- .../engine/datafacade/internal_datafacade.hpp | 21 ++++------------- src/storage/storage.cpp | 23 ++----------------- 2 files changed, 7 insertions(+), 37 deletions(-) diff --git a/include/engine/datafacade/internal_datafacade.hpp b/include/engine/datafacade/internal_datafacade.hpp index 781f0a548..302af30cc 100644 --- a/include/engine/datafacade/internal_datafacade.hpp +++ b/include/engine/datafacade/internal_datafacade.hpp @@ -101,24 +101,13 @@ class InternalDataFacade final : public BaseDataFacade void LoadTimestamp(const boost::filesystem::path ×tamp_path) { - if (boost::filesystem::exists(timestamp_path)) + util::SimpleLogger().Write() << "Loading Timestamp"; + boost::filesystem::ifstream timestamp_stream(timestamp_path); + if (!timestamp_stream) { - util::SimpleLogger().Write() << "Loading Timestamp"; - boost::filesystem::ifstream timestamp_stream(timestamp_path); - if (!timestamp_stream) - { - util::SimpleLogger().Write(logWARNING) << timestamp_path << " not found"; - } - getline(timestamp_stream, m_timestamp); - } - if (m_timestamp.empty()) - { - m_timestamp = "n/a"; - } - if (25 < m_timestamp.length()) - { - m_timestamp.resize(25); + throw util::exception("Could not open " + timestamp_path.string() + " for reading."); } + getline(timestamp_stream, m_timestamp); } void LoadGraph(const boost::filesystem::path &hsgr_path) diff --git a/src/storage/storage.cpp b/src/storage/storage.cpp index 515d7de02..6eac15e47 100644 --- a/src/storage/storage.cpp +++ b/src/storage/storage.cpp @@ -216,28 +216,9 @@ int Storage::Run() shared_layout_ptr->SetBlockSize(SharedDataLayout::PROPERTIES, 1); // load timestamp size + boost::filesystem::ifstream timestamp_stream(config.timestamp_path); std::string m_timestamp; - if (boost::filesystem::exists(config.timestamp_path)) - { - boost::filesystem::ifstream timestamp_stream(config.timestamp_path); - if (!timestamp_stream) - { - util::SimpleLogger().Write(logWARNING) << config.timestamp_path - << " not found. setting to default"; - } - else - { - getline(timestamp_stream, m_timestamp); - } - } - if (m_timestamp.empty()) - { - m_timestamp = "n/a"; - } - if (25 < m_timestamp.length()) - { - m_timestamp.resize(25); - } + getline(timestamp_stream, m_timestamp); shared_layout_ptr->SetBlockSize(SharedDataLayout::TIMESTAMP, m_timestamp.length()); // load core marker size