Mercurial > hg > orthanc
comparison OrthancServer/ServerIndex.cpp @ 3019:8336204d95dc db-changes
refactoring computation of disk size for recycling
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 Dec 2018 18:07:40 +0100 |
parents | 0e1755e5efd0 |
children | d207f6ac1f86 |
comparison
equal
deleted
inserted
replaced
3018:e3b5c07146a3 | 3019:8336204d95dc |
---|---|
213 | 213 |
214 class ServerIndex::Transaction | 214 class ServerIndex::Transaction |
215 { | 215 { |
216 private: | 216 private: |
217 ServerIndex& index_; | 217 ServerIndex& index_; |
218 std::auto_ptr<SQLite::ITransaction> transaction_; | 218 std::auto_ptr<IDatabaseWrapper::ITransaction> transaction_; |
219 bool isCommitted_; | 219 bool isCommitted_; |
220 | 220 |
221 public: | 221 public: |
222 Transaction(ServerIndex& index) : | 222 Transaction(ServerIndex& index) : |
223 index_(index), | 223 index_(index), |
243 | 243 |
244 void Commit(uint64_t sizeOfAddedFiles) | 244 void Commit(uint64_t sizeOfAddedFiles) |
245 { | 245 { |
246 if (!isCommitted_) | 246 if (!isCommitted_) |
247 { | 247 { |
248 transaction_->Commit(); | 248 int64_t delta = (static_cast<int64_t>(sizeOfAddedFiles) - |
249 static_cast<int64_t>(index_.listener_->GetSizeOfFilesToRemove())); | |
250 | |
251 transaction_->Commit(delta); | |
249 | 252 |
250 // We can remove the files once the SQLite transaction has | 253 // We can remove the files once the SQLite transaction has |
251 // been successfully committed. Some files might have to be | 254 // been successfully committed. Some files might have to be |
252 // deleted because of recycling. | 255 // deleted because of recycling. |
253 index_.listener_->CommitFilesToRemove(); | 256 index_.listener_->CommitFilesToRemove(); |