# HG changeset patch # User Sebastien Jodogne # Date 1607952409 -3600 # Node ID 4a3ba4bf4ba7d4749d190df57cdd0b0624137291 # Parent e980d584434a5339a904eeb51fe387b9a4e58869 making ServerIndex::IncrementGlobalSequence() more fault-tolerant diff -r e980d584434a -r 4a3ba4bf4ba7 OrthancServer/Sources/ServerIndex.cpp --- 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(oldValue); - db_.SetGlobalProperty(property, boost::lexical_cast(oldNumber + 1)); - return oldNumber + 1; + oldNumber = boost::lexical_cast(oldValue); } catch (boost::bad_lexical_cast&) { - throw OrthancException(ErrorCode_InternalError); + LOG(ERROR) << "Cannot read the global sequence " + << boost::lexical_cast(property) << ", resetting it"; + oldNumber = 0; } + + db_.SetGlobalProperty(property, boost::lexical_cast(oldNumber + 1)); + return oldNumber + 1; } else {