Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.cpp @ 2825:8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 19 Sep 2018 15:24:01 +0200 |
parents | 46061a91c88a |
children | c277e0421200 |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Tue Sep 18 16:31:42 2018 +0200 +++ b/OrthancServer/ServerIndex.cpp Wed Sep 19 15:24:01 2018 +0200 @@ -626,15 +626,26 @@ { Transaction t(*this); - // Do nothing if the instance already exists + // Check whether this instance is already stored { ResourceType type; int64_t tmp; if (db_.LookupResource(tmp, type, hasher.HashInstance())) { assert(type == ResourceType_Instance); - db_.GetAllMetadata(instanceMetadata, tmp); - return StoreStatus_AlreadyStored; + + if (overwrite_) + { + // Overwrite the old instance + LOG(INFO) << "Overwriting instance: " << hasher.HashInstance(); + db_.DeleteResource(tmp); + } + else + { + // Do nothing if the instance already exists + db_.GetAllMetadata(instanceMetadata, tmp); + return StoreStatus_AlreadyStored; + } } } @@ -1461,6 +1472,13 @@ StandaloneRecycling(); } + void ServerIndex::SetOverwriteInstances(bool overwrite) + { + boost::mutex::scoped_lock lock(mutex_); + overwrite_ = overwrite; + } + + void ServerIndex::StandaloneRecycling() { // WARNING: No mutex here, do not include this as a public method