Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerIndex.cpp @ 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 | 0ae2ca210077 |
children | d9473bd5ed43 |
comparison
equal
deleted
inserted
replaced
4370:e980d584434a | 4371:4a3ba4bf4ba7 |
---|---|
644 { | 644 { |
645 std::string oldValue; | 645 std::string oldValue; |
646 | 646 |
647 if (db_.LookupGlobalProperty(oldValue, property)) | 647 if (db_.LookupGlobalProperty(oldValue, property)) |
648 { | 648 { |
649 uint64_t oldNumber; | |
650 | |
649 try | 651 try |
650 { | 652 { |
651 uint64_t oldNumber = boost::lexical_cast<uint64_t>(oldValue); | 653 oldNumber = boost::lexical_cast<uint64_t>(oldValue); |
652 db_.SetGlobalProperty(property, boost::lexical_cast<std::string>(oldNumber + 1)); | |
653 return oldNumber + 1; | |
654 } | 654 } |
655 catch (boost::bad_lexical_cast&) | 655 catch (boost::bad_lexical_cast&) |
656 { | 656 { |
657 throw OrthancException(ErrorCode_InternalError); | 657 LOG(ERROR) << "Cannot read the global sequence " |
658 } | 658 << boost::lexical_cast<std::string>(property) << ", resetting it"; |
659 oldNumber = 0; | |
660 } | |
661 | |
662 db_.SetGlobalProperty(property, boost::lexical_cast<std::string>(oldNumber + 1)); | |
663 return oldNumber + 1; | |
659 } | 664 } |
660 else | 665 else |
661 { | 666 { |
662 // Initialize the sequence at "1" | 667 // Initialize the sequence at "1" |
663 db_.SetGlobalProperty(property, "1"); | 668 db_.SetGlobalProperty(property, "1"); |