diff OrthancServer/ServerIndex.cpp @ 1189:6b9b02a16e99 db-changes

NewChildInstance change type
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 25 Sep 2014 17:02:28 +0200
parents 5b2d8c280ac2
children d49505e377e3
line wrap: on
line diff
--- a/OrthancServer/ServerIndex.cpp	Thu Sep 25 16:42:19 2014 +0200
+++ b/OrthancServer/ServerIndex.cpp	Thu Sep 25 17:02:28 2014 +0200
@@ -138,6 +138,7 @@
         sizeOfFilesToRemove_ = 0;
         hasRemainingLevel_ = false;
         pendingFilesToRemove_.clear();
+        pendingChanges_.clear();
       }
 
       uint64_t GetSizeOfFilesToRemove()
@@ -147,7 +148,7 @@
 
       void CommitFilesToRemove()
       {
-        for (std::list<FileToRemove>::iterator 
+        for (std::list<FileToRemove>::const_iterator 
                it = pendingFilesToRemove_.begin();
              it != pendingFilesToRemove_.end(); ++it)
         {
@@ -155,6 +156,16 @@
         }
       }
 
+      void CommitChanges()
+      {
+        for (std::list<Change>::const_iterator 
+               it = pendingChanges_.begin(); 
+             it != pendingChanges_.end(); it++)
+        {
+          context_.SignalChange(it->GetChangeType(), it->GetResourceType(), it->GetPublicId());
+        }
+      }
+
       virtual void SignalRemainingAncestor(ResourceType parentType,
                                            const std::string& publicId)
       {
@@ -250,6 +261,9 @@
 
         assert(index_.currentStorageSize_ == index_.db_->GetTotalCompressedSize());
 
+        // Send all the pending changes to the Orthanc plugins
+        index_.listener_->CommitChanges();
+
         isCommitted_ = true;
       }
     }
@@ -1695,6 +1709,8 @@
     UnstableResourcePayload payload(type, publicId);
     unstableResources_.AddOrMakeMostRecent(id, payload);
     //LOG(INFO) << "Unstable resource: " << EnumerationToString(type) << " " << id;
+
+    db_->LogChange(ChangeType_NewChildInstance, id, type, publicId);
   }