Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.cpp @ 702:7592a48e97e4
delete custom attachment
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 Feb 2014 17:28:17 +0100 |
parents | f9052558eada |
children | 4789da60d655 |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Mon Feb 10 14:30:56 2014 +0100 +++ b/OrthancServer/ServerIndex.cpp Tue Feb 11 17:28:17 2014 +0100 @@ -1339,22 +1339,22 @@ ResourceType thisType = db_->GetResourceType(resource); + std::list<FileContentType> f; + db_->ListAvailableAttachments(f, resource); + + for (std::list<FileContentType>::const_iterator + it = f.begin(); it != f.end(); ++it) + { + FileInfo attachment; + if (db_->LookupAttachment(attachment, resource, *it)) + { + compressedSize += attachment.GetCompressedSize(); + uncompressedSize += attachment.GetUncompressedSize(); + } + } + if (thisType == ResourceType_Instance) { - std::list<FileContentType> f; - db_->ListAvailableAttachments(f, resource); - - for (std::list<FileContentType>::const_iterator - it = f.begin(); it != f.end(); ++it) - { - FileInfo attachment; - if (db_->LookupAttachment(attachment, resource, *it)) - { - compressedSize += attachment.GetCompressedSize(); - uncompressedSize += attachment.GetUncompressedSize(); - } - } - countInstances++; } else @@ -1618,4 +1618,26 @@ return StoreStatus_Success; } + + void ServerIndex::DeleteAttachment(const std::string& publicId, + FileContentType type) + { + boost::mutex::scoped_lock lock(mutex_); + listener_->Reset(); + + Transaction t(*this); + + ResourceType rtype; + int64_t id; + if (!db_->LookupResource(publicId, id, rtype)) + { + throw OrthancException(ErrorCode_UnknownResource); + } + + db_->DeleteAttachment(id, type); + + t.Commit(0); + } + + }