changeset 1300:919dfb2fb3fe

DANGEROUS refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 06 Feb 2015 15:30:46 +0100
parents 4ce47e8ed0d2
children 5d56cfa49f68
files OrthancServer/DatabaseWrapper.cpp OrthancServer/ServerIndex.cpp
diffstat 2 files changed, 18 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/DatabaseWrapper.cpp	Fri Feb 06 15:13:05 2015 +0100
+++ b/OrthancServer/DatabaseWrapper.cpp	Fri Feb 06 15:30:46 2015 +0100
@@ -573,18 +573,12 @@
   void DatabaseWrapper::LogChange(int64_t internalId,
                                   const ServerIndexChange& change)
   {
-    if (change.GetChangeType() <= ChangeType_INTERNAL_LastLogged)
-    {
-      SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Changes VALUES(NULL, ?, ?, ?, ?)");
-      s.BindInt(0, change.GetChangeType());
-      s.BindInt64(1, internalId);
-      s.BindInt(2, change.GetResourceType());
-      s.BindString(3, change.GetDate());
-      s.Run();
-    }
-
-    assert(listener_ != NULL);
-    listener_->SignalChange(change);
+    SQLite::Statement s(db_, SQLITE_FROM_HERE, "INSERT INTO Changes VALUES(NULL, ?, ?, ?, ?)");
+    s.BindInt(0, change.GetChangeType());
+    s.BindInt64(1, internalId);
+    s.BindInt(2, change.GetResourceType());
+    s.BindString(3, change.GetDate());
+    s.Run();
   }
 
 
--- a/OrthancServer/ServerIndex.cpp	Fri Feb 06 15:13:05 2015 +0100
+++ b/OrthancServer/ServerIndex.cpp	Fri Feb 06 15:30:46 2015 +0100
@@ -447,7 +447,14 @@
                               const std::string& publicId)
   {
     ServerIndexChange change(changeType, resourceType, publicId);
-    db_.LogChange(internalId, change);
+
+    if (changeType <= ChangeType_INTERNAL_LastLogged)
+    {
+      db_.LogChange(internalId, change);
+    }
+
+    assert(listener_.get() != NULL);
+    listener_->SignalChange(change);
   }
 
 
@@ -522,6 +529,10 @@
 
     ServerIndexChange change(changeType, type, publicId);
     db_.LogChange(id, change);
+
+    assert(listener_.get() != NULL);
+    listener_->SignalChange(change);
+
     return id;
   }