[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/nepomuk/services/backupsync/service
From:       Vishesh Handa <handa.vish () gmail ! com>
Date:       2011-01-25 7:32:06
Message-ID: 20110125073206.24A54AC8B9 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1216929 by vhanda:

* Return the number of records saved in saveBackupChangeLog()
* Add a check to see if the records are properly serialized - return an empty QString \
if they are not



 M  +4 -1      changelogrecord.cpp  
 M  +8 -5      tools.cpp  
 M  +3 -1      tools.h  


--- trunk/KDE/kdebase/runtime/nepomuk/services/backupsync/service/changelogrecord.cpp \
#1216928:1216929 @@ -128,7 +128,10 @@
     QString statement;
     QTextStream ts( &statement );
 
-    Private::serializer->serialize( it, ts, Soprano::SerializationNQuads);
+    if( !Private::serializer->serialize( it, ts, Soprano::SerializationNQuads) ) {
+        kWarning() << "Serialization using NQuads failed for " << d->st;
+        return QString();
+    }
 
     return s + statement;
 }
--- trunk/KDE/kdebase/runtime/nepomuk/services/backupsync/service/tools.cpp \
#1216928:1216929 @@ -35,23 +35,23 @@
 #include <KDebug>
 
 
-void Nepomuk::saveBackupChangeLog(const QUrl& url)
+int Nepomuk::saveBackupChangeLog(const QUrl& url)
 {
     const int step = 100;
-    
-    ChangeLog changeLog;
-    
     const QString query = QString::fromLatin1("select ?r ?p ?o ?g where { graph ?g { \
?r ?p ?o. } ?g a nrl:InstanceBase . FILTER(!bif:exists( ( select (1) where { ?g a \
nrl:DiscardableInstanceBase . } ) )) . }");  
     Soprano::Model * model = Nepomuk::ResourceManager::instance()->mainModel();
     
     Soprano::QueryResultIterator iter= model->executeQuery( query, \
Soprano::Query::QueryLanguageSparql );  
+    int totalNumRecords = 0;
     int i=0;
+    ChangeLog changeLog;
     while( iter.next() ) {
         Soprano::Statement st( iter["r"], iter["p"], iter["o"], iter["g"] );
          //kDebug() << st;
         changeLog += ChangeLogRecord( st );
+        totalNumRecords++;
 
         if( ++i >= step ) {
             //kDebug() << "Saving .. " << changeLog.size();
@@ -62,6 +62,8 @@
     }
 
     changeLog.save( url );
+    kDebug() << "Total Records : " << totalNumRecords;
+    return totalNumRecords;
 }
 
 //TODO: This doesn't really solve the problem that the backup maybe huge and
@@ -74,9 +76,10 @@
     KTemporaryFile file;
     file.open();
 
-    saveBackupChangeLog( file.fileName() );
+    int numRecords = saveBackupChangeLog( file.fileName() );
     ChangeLog log = ChangeLog::fromUrl( file.fileName() );
     kDebug() << "Log size: " << log.size();
+    Q_ASSERT( numRecords == log.size() );
 
     if( log.empty() ) {
         kDebug() << "Nothing to save..";
--- trunk/KDE/kdebase/runtime/nepomuk/services/backupsync/service/tools.h \
#1216928:1216929 @@ -36,8 +36,10 @@
     /**
      * Saves a changeLog with the list of all the statements that should be backed \
                up.
      * It's useful in when doing a first sync or first backup.
+     *
+     * Returns the numbers of records in the changelog
      */
-    void saveBackupChangeLog( const QUrl& url );
+    int saveBackupChangeLog( const QUrl& url );
 
     bool saveBackupSyncFile( const QUrl& url );
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic