Mercurial > hg > orthanc-webviewer
comparison Plugin/Cache/CacheManager.cpp @ 23:7a0af291cc90
Synchronization with Orthanc mainline
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 01 Jun 2015 11:52:28 +0200 |
parents | 02f7a0400a91 |
children | a6492d20b2a8 |
comparison
equal
deleted
inserted
replaced
22:b42eeb4bd1e3 | 23:7a0af291cc90 |
---|---|
224 | 224 |
225 transaction->Commit(); | 225 transaction->Commit(); |
226 for (std::list<std::string>::const_iterator | 226 for (std::list<std::string>::const_iterator |
227 it = toRemove.begin(); it != toRemove.end(); it++) | 227 it = toRemove.begin(); it != toRemove.end(); it++) |
228 { | 228 { |
229 pimpl_->storage_.Remove(*it); | 229 pimpl_->storage_.Remove(*it, Orthanc::FileContentType_Unknown); |
230 } | 230 } |
231 | 231 |
232 pimpl_->bundles_[bundleIndex] = bundle; | 232 pimpl_->bundles_[bundleIndex] = bundle; |
233 } | 233 } |
234 | 234 |
337 MakeRoom(bundle, toRemove, bundleIndex, quota); | 337 MakeRoom(bundle, toRemove, bundleIndex, quota); |
338 | 338 |
339 // Store the cached content on the disk | 339 // Store the cached content on the disk |
340 const char* data = content.size() ? &content[0] : NULL; | 340 const char* data = content.size() ? &content[0] : NULL; |
341 std::string uuid = Toolbox::GenerateUuid(); | 341 std::string uuid = Toolbox::GenerateUuid(); |
342 pimpl_->storage_.Create(uuid, data, content.size()); | 342 pimpl_->storage_.Create(uuid, data, content.size(), Orthanc::FileContentType_Unknown); |
343 | 343 |
344 bool ok = true; | 344 bool ok = true; |
345 | 345 |
346 // Remove the previous cached value. This might happen if the same | 346 // Remove the previous cached value. This might happen if the same |
347 // item is accessed very quickly twice: Another factory could have | 347 // item is accessed very quickly twice: Another factory could have |
376 } | 376 } |
377 | 377 |
378 if (!ok) | 378 if (!ok) |
379 { | 379 { |
380 // Error: Remove the stored file | 380 // Error: Remove the stored file |
381 pimpl_->storage_.Remove(uuid); | 381 pimpl_->storage_.Remove(uuid, Orthanc::FileContentType_Unknown); |
382 } | 382 } |
383 else | 383 else |
384 { | 384 { |
385 transaction->Commit(); | 385 transaction->Commit(); |
386 | 386 |
387 pimpl_->bundles_[bundleIndex] = bundle; | 387 pimpl_->bundles_[bundleIndex] = bundle; |
388 | 388 |
389 for (std::list<std::string>::const_iterator | 389 for (std::list<std::string>::const_iterator |
390 it = toRemove.begin(); it != toRemove.end(); it++) | 390 it = toRemove.begin(); it != toRemove.end(); it++) |
391 { | 391 { |
392 pimpl_->storage_.Remove(*it); | 392 pimpl_->storage_.Remove(*it, Orthanc::FileContentType_Unknown); |
393 } | 393 } |
394 } | 394 } |
395 | 395 |
396 SanityCheck(); | 396 SanityCheck(); |
397 } | 397 } |
464 } | 464 } |
465 | 465 |
466 bool ok; | 466 bool ok; |
467 try | 467 try |
468 { | 468 { |
469 pimpl_->storage_.Read(content, uuid); | 469 pimpl_->storage_.Read(content, uuid, Orthanc::FileContentType_Unknown); |
470 ok = (content.size() == size); | 470 ok = (content.size() == size); |
471 } | 471 } |
472 catch (std::runtime_error&) | 472 catch (std::runtime_error&) |
473 { | 473 { |
474 ok = false; | 474 ok = false; |
510 t.BindInt64(0, seq); | 510 t.BindInt64(0, seq); |
511 if (t.Run()) | 511 if (t.Run()) |
512 { | 512 { |
513 transaction->Commit(); | 513 transaction->Commit(); |
514 pimpl_->bundles_[bundleIndex] = bundle; | 514 pimpl_->bundles_[bundleIndex] = bundle; |
515 pimpl_->storage_.Remove(uuid); | 515 pimpl_->storage_.Remove(uuid, Orthanc::FileContentType_Unknown); |
516 } | 516 } |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 | 520 |
556 SanityCheck(); | 556 SanityCheck(); |
557 | 557 |
558 SQLite::Statement s(pimpl_->db_, SQLITE_FROM_HERE, "SELECT fileUuid FROM Cache"); | 558 SQLite::Statement s(pimpl_->db_, SQLITE_FROM_HERE, "SELECT fileUuid FROM Cache"); |
559 while (s.Step()) | 559 while (s.Step()) |
560 { | 560 { |
561 pimpl_->storage_.Remove(s.ColumnString(0)); | 561 pimpl_->storage_.Remove(s.ColumnString(0), Orthanc::FileContentType_Unknown); |
562 } | 562 } |
563 | 563 |
564 SQLite::Statement t(pimpl_->db_, SQLITE_FROM_HERE, "DELETE FROM Cache"); | 564 SQLite::Statement t(pimpl_->db_, SQLITE_FROM_HERE, "DELETE FROM Cache"); |
565 t.Run(); | 565 t.Run(); |
566 | 566 |
577 | 577 |
578 SQLite::Statement s(pimpl_->db_, SQLITE_FROM_HERE, "SELECT fileUuid FROM Cache WHERE bundle=?"); | 578 SQLite::Statement s(pimpl_->db_, SQLITE_FROM_HERE, "SELECT fileUuid FROM Cache WHERE bundle=?"); |
579 s.BindInt(0, bundle); | 579 s.BindInt(0, bundle); |
580 while (s.Step()) | 580 while (s.Step()) |
581 { | 581 { |
582 pimpl_->storage_.Remove(s.ColumnString(0)); | 582 pimpl_->storage_.Remove(s.ColumnString(0), Orthanc::FileContentType_Unknown); |
583 } | 583 } |
584 | 584 |
585 SQLite::Statement t(pimpl_->db_, SQLITE_FROM_HERE, "DELETE FROM Cache WHERE bundle=?"); | 585 SQLite::Statement t(pimpl_->db_, SQLITE_FROM_HERE, "DELETE FROM Cache WHERE bundle=?"); |
586 t.BindInt(0, bundle); | 586 t.BindInt(0, bundle); |
587 t.Run(); | 587 t.Run(); |