Mercurial > hg > orthanc
comparison 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 |
comparison
equal
deleted
inserted
replaced
698:aae83e1e31f7 | 699:2929e17f8447 |
---|---|
1591 it = id.begin(); it != id.end(); ++it) | 1591 it = id.begin(); it != id.end(); ++it) |
1592 { | 1592 { |
1593 result.push_back(db_->GetPublicId(*it)); | 1593 result.push_back(db_->GetPublicId(*it)); |
1594 } | 1594 } |
1595 } | 1595 } |
1596 | |
1597 | |
1598 StoreStatus ServerIndex::AddAttachment(const FileInfo& attachment, | |
1599 const std::string& publicId) | |
1600 { | |
1601 boost::mutex::scoped_lock lock(mutex_); | |
1602 | |
1603 Transaction t(*this); | |
1604 | |
1605 ResourceType resourceType; | |
1606 int64_t resourceId; | |
1607 if (!db_->LookupResource(publicId, resourceId, resourceType)) | |
1608 { | |
1609 return StoreStatus_Failure; // Inexistent resource | |
1610 } | |
1611 | |
1612 db_->DeleteAttachment(resourceId, attachment.GetContentType()); | |
1613 | |
1614 // TODO Integrate the recycling mechanism!! | |
1615 db_->AddAttachment(resourceId, attachment); | |
1616 | |
1617 t.Commit(attachment.GetCompressedSize()); | |
1618 | |
1619 return StoreStatus_Success; | |
1620 } | |
1621 | |
1596 } | 1622 } |