Mercurial > hg > orthanc
diff Plugins/Engine/OrthancPluginDatabase.cpp @ 1673:0bbcfd9695e5 db-changes
UpgradeDatabase in the sample plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 02 Oct 2015 13:26:05 +0200 |
parents | 4c5a85c3ff43 |
children | 2ad22b2970a2 |
line wrap: on
line diff
--- a/Plugins/Engine/OrthancPluginDatabase.cpp Fri Oct 02 12:20:49 2015 +0200 +++ b/Plugins/Engine/OrthancPluginDatabase.cpp Fri Oct 02 13:26:05 2015 +0200 @@ -692,7 +692,7 @@ void OrthancPluginDatabase::ClearMainDicomTags(int64_t id) { - if (extensions_.clearMainDicomTags != NULL) + if (extensions_.clearMainDicomTags == NULL) { LOG(ERROR) << "Your custom index plugin does not implement the ClearMainDicomTags() extension"; throw OrthancException(ErrorCode_DatabasePlugin); @@ -848,9 +848,23 @@ { if (extensions_.upgradeDatabase != NULL) { - CheckSuccess(extensions_.upgradeDatabase( - payload_, targetVersion, - reinterpret_cast<OrthancPluginStorageArea*>(&storageArea))); + Transaction transaction(backend_, payload_, errorDictionary_); + transaction.Begin(); + + OrthancPluginErrorCode code = extensions_.upgradeDatabase( + payload_, targetVersion, + reinterpret_cast<OrthancPluginStorageArea*>(&storageArea)); + + if (code == OrthancPluginErrorCode_Success) + { + transaction.Commit(); + } + else + { + transaction.Rollback(); + errorDictionary_.LogError(code, true); + throw OrthancException(static_cast<ErrorCode>(code)); + } } }