Mercurial > hg > orthanc
changeset 4371:4a3ba4bf4ba7
making ServerIndex::IncrementGlobalSequence() more fault-tolerant
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 14 Dec 2020 14:26:49 +0100 |
parents | e980d584434a |
children | bda867e036f3 |
files | OrthancServer/Sources/ServerIndex.cpp |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerIndex.cpp Sat Dec 12 19:42:05 2020 +0100 +++ b/OrthancServer/Sources/ServerIndex.cpp Mon Dec 14 14:26:49 2020 +0100 @@ -646,16 +646,21 @@ if (db_.LookupGlobalProperty(oldValue, property)) { + uint64_t oldNumber; + try { - uint64_t oldNumber = boost::lexical_cast<uint64_t>(oldValue); - db_.SetGlobalProperty(property, boost::lexical_cast<std::string>(oldNumber + 1)); - return oldNumber + 1; + oldNumber = boost::lexical_cast<uint64_t>(oldValue); } catch (boost::bad_lexical_cast&) { - throw OrthancException(ErrorCode_InternalError); + LOG(ERROR) << "Cannot read the global sequence " + << boost::lexical_cast<std::string>(property) << ", resetting it"; + oldNumber = 0; } + + db_.SetGlobalProperty(property, boost::lexical_cast<std::string>(oldNumber + 1)); + return oldNumber + 1; } else {