Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.cpp @ 3082:847a0ed92654 db-changes
new extension for database plugin SDK: createInstance
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Jan 2019 13:52:34 +0100 |
parents | 1a75595d8e44 |
children | 683d572424b6 |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Thu Jan 03 20:03:35 2019 +0100 +++ b/OrthancServer/ServerIndex.cpp Fri Jan 04 13:52:34 2019 +0100 @@ -720,11 +720,29 @@ // Check whether this instance is already stored if (!db_.CreateInstance(status, instanceId, hashPatient, - hashStudy, hashSeries, hashInstance, overwrite_)) + hashStudy, hashSeries, hashInstance)) { - // Do nothing if the instance already exists and overwriting is disabled - db_.GetAllMetadata(instanceMetadata, instanceId); - return StoreStatus_AlreadyStored; + // The instance already exists + + if (overwrite_) + { + // Overwrite the old instance + LOG(INFO) << "Overwriting instance: " << hashInstance; + db_.DeleteResource(instanceId); + + // Re-create the instance, now that the old one is removed + if (!db_.CreateInstance(status, instanceId, hashPatient, + hashStudy, hashSeries, hashInstance)) + { + throw OrthancException(ErrorCode_InternalError); + } + } + else + { + // Do nothing if the instance already exists and overwriting is disabled + db_.GetAllMetadata(instanceMetadata, instanceId); + return StoreStatus_AlreadyStored; + } }