comparison 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
comparison
equal deleted inserted replaced
701:f9052558eada 702:7592a48e97e4
1337 int64_t resource = toExplore.top(); 1337 int64_t resource = toExplore.top();
1338 toExplore.pop(); 1338 toExplore.pop();
1339 1339
1340 ResourceType thisType = db_->GetResourceType(resource); 1340 ResourceType thisType = db_->GetResourceType(resource);
1341 1341
1342 std::list<FileContentType> f;
1343 db_->ListAvailableAttachments(f, resource);
1344
1345 for (std::list<FileContentType>::const_iterator
1346 it = f.begin(); it != f.end(); ++it)
1347 {
1348 FileInfo attachment;
1349 if (db_->LookupAttachment(attachment, resource, *it))
1350 {
1351 compressedSize += attachment.GetCompressedSize();
1352 uncompressedSize += attachment.GetUncompressedSize();
1353 }
1354 }
1355
1342 if (thisType == ResourceType_Instance) 1356 if (thisType == ResourceType_Instance)
1343 { 1357 {
1344 std::list<FileContentType> f;
1345 db_->ListAvailableAttachments(f, resource);
1346
1347 for (std::list<FileContentType>::const_iterator
1348 it = f.begin(); it != f.end(); ++it)
1349 {
1350 FileInfo attachment;
1351 if (db_->LookupAttachment(attachment, resource, *it))
1352 {
1353 compressedSize += attachment.GetCompressedSize();
1354 uncompressedSize += attachment.GetUncompressedSize();
1355 }
1356 }
1357
1358 countInstances++; 1358 countInstances++;
1359 } 1359 }
1360 else 1360 else
1361 { 1361 {
1362 switch (thisType) 1362 switch (thisType)
1616 t.Commit(attachment.GetCompressedSize()); 1616 t.Commit(attachment.GetCompressedSize());
1617 1617
1618 return StoreStatus_Success; 1618 return StoreStatus_Success;
1619 } 1619 }
1620 1620
1621
1622 void ServerIndex::DeleteAttachment(const std::string& publicId,
1623 FileContentType type)
1624 {
1625 boost::mutex::scoped_lock lock(mutex_);
1626 listener_->Reset();
1627
1628 Transaction t(*this);
1629
1630 ResourceType rtype;
1631 int64_t id;
1632 if (!db_->LookupResource(publicId, id, rtype))
1633 {
1634 throw OrthancException(ErrorCode_UnknownResource);
1635 }
1636
1637 db_->DeleteAttachment(id, type);
1638
1639 t.Commit(0);
1640 }
1641
1642
1621 } 1643 }