# HG changeset patch # User Sebastien Jodogne # Date 1615225333 -3600 # Node ID f6cd49af752612e5de54f1eac7e97ffa25965658 # Parent e23bacd4fffc3a92d6f29ae3383ba69899ee5df2 cont diff -r e23bacd4fffc -r f6cd49af7526 OrthancServer/Sources/ServerIndex.cpp --- a/OrthancServer/Sources/ServerIndex.cpp Mon Mar 08 18:30:06 2021 +0100 +++ b/OrthancServer/Sources/ServerIndex.cpp Mon Mar 08 18:42:13 2021 +0100 @@ -251,12 +251,14 @@ ServerIndex& index_; std::unique_ptr transaction_; bool isCommitted_; + uint64_t sizeOfAddedAttachments_; public: explicit Transaction(ServerIndex& index, TransactionType type) : index_(index), - isCommitted_(false) + isCommitted_(false), + sizeOfAddedAttachments_(0) { transaction_.reset(index_.db_.StartTransaction(type)); index_.listener_->StartTransaction(); @@ -272,11 +274,16 @@ } } - void Commit(uint64_t sizeOfAddedFiles) + void SignalAttachmentsAdded(uint64_t compressedSize) + { + sizeOfAddedAttachments_ += compressedSize; + } + + void Commit() { if (!isCommitted_) { - int64_t delta = (static_cast(sizeOfAddedFiles) - + int64_t delta = (static_cast(sizeOfAddedAttachments_) - static_cast(index_.listener_->GetSizeOfFilesToRemove())); transaction_->Commit(delta); @@ -955,7 +962,8 @@ MarkAsUnstable(status.studyId_, ResourceType_Study, hashStudy); MarkAsUnstable(status.patientId_, ResourceType_Patient, hashPatient); - t.Commit(instanceSize); + t.SignalAttachmentsAdded(instanceSize); + t.Commit(); return StoreStatus_Success; } @@ -1202,7 +1210,7 @@ // WARNING: No mutex here, do not include this as a public method Transaction t(*this, TransactionType_ReadWrite); Recycle(0, ""); - t.Commit(0); + t.Commit(); } @@ -1333,7 +1341,8 @@ LogChange(resourceId, ChangeType_UpdatedAttachment, resourceType, publicId); } - t.Commit(attachment.GetCompressedSize()); + t.SignalAttachmentsAdded(attachment.GetCompressedSize()); + t.Commit(); return StoreStatus_Success; } @@ -1607,7 +1616,7 @@ ReadOnlyTransaction t(db_); readOperations->Apply(t); } - transaction.Commit(0); + transaction.Commit(); } else { @@ -1619,7 +1628,7 @@ ReadWriteTransaction t(db_, *listener_, *this); writeOperations->Apply(t); } - transaction.Commit(0); + transaction.Commit(); } return; // Success