Replace fingerprint with semver-based scheme. (#3467)
This commit is contained in:
+26
-6
@@ -5,6 +5,7 @@
|
||||
#include "util/exception_utils.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/log.hpp"
|
||||
#include "util/version.hpp"
|
||||
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
#include <boost/iostreams/seek.hpp>
|
||||
@@ -117,12 +118,31 @@ class FileReader
|
||||
|
||||
bool ReadAndCheckFingerprint()
|
||||
{
|
||||
auto fingerprint = ReadOne<util::FingerPrint>();
|
||||
const auto valid = util::FingerPrint::GetValid();
|
||||
// compare the compilation state stored in the fingerprint
|
||||
return valid.IsMagicNumberOK(fingerprint) && valid.TestContractor(fingerprint) &&
|
||||
valid.TestGraphUtil(fingerprint) && valid.TestRTree(fingerprint) &&
|
||||
valid.TestQueryObjects(fingerprint);
|
||||
auto loaded_fingerprint = ReadOne<util::FingerPrint>();
|
||||
const auto expected_fingerprint = util::FingerPrint::GetValid();
|
||||
|
||||
if (!loaded_fingerprint.IsValid())
|
||||
{
|
||||
util::Log(logERROR) << "Fingerprint magic number or checksum is invalid in "
|
||||
<< filepath.string();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!expected_fingerprint.IsDataCompatible(loaded_fingerprint))
|
||||
{
|
||||
util::Log(logERROR) << filepath.string()
|
||||
<< " is not compatible with this version of OSRM";
|
||||
|
||||
util::Log(logERROR) << "It was prepared with OSRM "
|
||||
<< loaded_fingerprint.GetMajorVersion() << "."
|
||||
<< loaded_fingerprint.GetMinorVersion() << "."
|
||||
<< loaded_fingerprint.GetPatchVersion() << " but you are running "
|
||||
<< OSRM_VERSION;
|
||||
util::Log(logERROR) << "Data is only compatible between minor releases.";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::size_t Size()
|
||||
|
||||
@@ -40,13 +40,6 @@ struct HSGRHeader
|
||||
// file and returns them in a HSGRHeader struct
|
||||
inline HSGRHeader readHSGRHeader(io::FileReader &input_file)
|
||||
{
|
||||
const util::FingerPrint fingerprint_valid = util::FingerPrint::GetValid();
|
||||
const auto fingerprint_loaded = input_file.ReadOne<util::FingerPrint>();
|
||||
if (!fingerprint_loaded.TestGraphUtil(fingerprint_valid))
|
||||
{
|
||||
util::Log(logWARNING) << ".hsgr was prepared with different build.\n"
|
||||
"Reprocess to get rid of this warning.";
|
||||
}
|
||||
|
||||
HSGRHeader header;
|
||||
input_file.ReadInto(header.checksum);
|
||||
|
||||
Reference in New Issue
Block a user