Mercurial > hg > orthanc
diff OrthancServer/ServerIndex.cpp @ 699:2929e17f8447
add attachments to resources
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 05 Feb 2014 17:49:30 +0100 |
parents | dd1ce9a2844c |
children | f9052558eada |
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp Wed Feb 05 17:20:43 2014 +0100 +++ b/OrthancServer/ServerIndex.cpp Wed Feb 05 17:49:30 2014 +0100 @@ -1593,4 +1593,30 @@ result.push_back(db_->GetPublicId(*it)); } } + + + StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment, + const std::string& publicId) + { + boost::mutex::scoped_lock lock(mutex_); + + Transaction t(*this); + + ResourceType resourceType; + int64_t resourceId; + if (!db_->LookupResource(publicId, resourceId, resourceType)) + { + return StoreStatus_Failure; // Inexistent resource + } + + db_->DeleteAttachment(resourceId, attachment.GetContentType()); + + // TODO Integrate the recycling mechanism!! + db_->AddAttachment(resourceId, attachment); + + t.Commit(attachment.GetCompressedSize()); + + return StoreStatus_Success; + } + }