Mercurial > hg > orthanc-webviewer
diff Plugin/Cache/CacheManager.cpp @ 197:0ef2d8b970ab
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 23 Apr 2018 11:42:31 +0200 |
parents | 993dd140bd30 |
children | 2f27287c047c |
line wrap: on
line diff
--- a/Plugin/Cache/CacheManager.cpp Fri Apr 20 14:23:34 2018 +0200 +++ b/Plugin/Cache/CacheManager.cpp Mon Apr 23 11:42:31 2018 +0200 @@ -228,7 +228,7 @@ transaction->Commit(); for (std::list<std::string>::const_iterator - it = toRemove.begin(); it != toRemove.end(); it++) + it = toRemove.begin(); it != toRemove.end(); ++it) { pimpl_->storage_.Remove(*it, Orthanc::FileContentType_Unknown); } @@ -357,8 +357,6 @@ std::string uuid = Toolbox::GenerateUuid(); pimpl_->storage_.Create(uuid, data, content.size(), Orthanc::FileContentType_Unknown); - bool ok = true; - // Remove the previous cached value. This might happen if the same // item is accessed very quickly twice: Another factory could have // been cached a value before the check for existence in Access(). @@ -377,7 +375,6 @@ } } - if (ok) { SQLite::Statement s(pimpl_->db_, SQLITE_FROM_HERE, "INSERT INTO Cache VALUES(NULL, ?, ?, ?, ?)"); s.BindInt(0, bundleIndex); @@ -387,25 +384,20 @@ if (!s.Run()) { - ok = false; + // Error: Remove the stored file + pimpl_->storage_.Remove(uuid, Orthanc::FileContentType_Unknown); } - } + else + { + transaction->Commit(); - if (!ok) - { - // Error: Remove the stored file - pimpl_->storage_.Remove(uuid, Orthanc::FileContentType_Unknown); - } - else - { - transaction->Commit(); - - pimpl_->bundles_[bundleIndex] = bundle; + pimpl_->bundles_[bundleIndex] = bundle; - for (std::list<std::string>::const_iterator - it = toRemove.begin(); it != toRemove.end(); it++) - { - pimpl_->storage_.Remove(*it, Orthanc::FileContentType_Unknown); + for (std::list<std::string>::const_iterator + it = toRemove.begin(); it != toRemove.end(); ++it) + { + pimpl_->storage_.Remove(*it, Orthanc::FileContentType_Unknown); + } } }