[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/nepomuk-kde/backupsync/service
From: Vishesh Handa <handa.vish () gmail ! com>
Date: 2010-08-01 20:47:05
Message-ID: 20100801204705.DBD36AC7A9 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1157990 by vhanda:
Added a method to get the first syncFile. It is required to perform the initial sync of two machines.
M +1 -0 CMakeLists.txt
M +4 -25 backupstorage.cpp
M +3 -0 logstorage.cpp
M +8 -0 syncmanager.cpp
M +1 -0 syncmanager.h
M +4 -0 syncrequest.cpp
A tools.cpp [License: GPL (v3+)]
A tools.h [License: GPL (v3+)]
--- trunk/playground/base/nepomuk-kde/backupsync/service/CMakeLists.txt #1157989:1157990
@@ -31,6 +31,7 @@
backupmanager.cpp
dbusoperators.cpp
syncrequest.cpp
+ tools.cpp
)
#--------- Adaptors ---------#
--- trunk/playground/base/nepomuk-kde/backupsync/service/backupstorage.cpp #1157989:1157990
@@ -18,6 +18,7 @@
*/
#include "backupstorage.h"
+#include "tools.h"
#include <nepomuk/syncfile.h>
#include <nepomuk/changelog.h>
@@ -52,11 +53,11 @@
}
-void Nepomuk::BackupStorage::add(const Nepomuk::Sync::ChangeLog& lf)
+void Nepomuk::BackupStorage::add(const Nepomuk::Sync::ChangeLog& log)
{
KTempDir dir;
QUrl url( dir.name() + "syncFile" );
- Sync::SyncFile sf( lf );
+ Sync::SyncFile sf( log );
sf.save( url );
add( url );
@@ -68,33 +69,11 @@
KZip zipFile( m_url );
zipFile.open( QIODevice::ReadWrite );
- QString fileName = QDateTime::currentDateTime().toUTC().toString();
+ QString fileName = QDateTime::currentDateTime()/*.toUTC()*/.toString();
zipFile.addLocalFile( syncFileUrl.toLocalFile(), fileName );
}
-namespace {
-
- //TODO: Move this somewhere else. It's usefull in cases like first sync.
- QList<Soprano::Statement> getBackupStatements()
- {
- 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 it = model->executeQuery( query, \
Soprano::Query::QueryLanguageSparql );
-
- QList<Soprano::Statement> statements;
- while( it.next() ) {
- Soprano::Statement st( it["r"], it["p"], it["o"], it["g"] );
- statements.append( st );
- }
-
- return statements;
- }
-
-}
-
-
void Nepomuk::BackupStorage::create()
{
//FIXME: The time stamps should be changed to UTC if UTC time is being used.
--- trunk/playground/base/nepomuk-kde/backupsync/service/logstorage.cpp #1157989:1157990
@@ -146,6 +146,9 @@
kDebug();
+ // Always sort them not mattter what. I don't know why I get weird results otherwise.
+ qSort( m_records );
+
QDir dir( m_dirUrl );
const QStringList& entries = dir.entryList( QDir::Files, QDir::Reversed );
--- trunk/playground/base/nepomuk-kde/backupsync/service/syncmanager.cpp #1157989:1157990
@@ -25,6 +25,7 @@
#include "diffgenerator.h"
#include "nao.h"
#include "syncmanageradaptor.h"
+#include "tools.h"
#include <QtDBus/QDBusConnection>
@@ -112,4 +113,11 @@
}
+void Nepomuk::SyncManager::createFirstSyncFile(const QUrl& outputUrl) const
+{
+ Sync::SyncFile sf = Nepomuk::createFirstSyncFile();
+ sf.save( outputUrl );
+}
+
+
#include "syncmanager.moc"
--- trunk/playground/base/nepomuk-kde/backupsync/service/syncmanager.h #1157989:1157990
@@ -48,6 +48,7 @@
void createSyncFile( const QString & url, const QString& startTime );
void createSyncFile( const QUrl& outputUrl, const QList<QString> & nieUrls );
void createSyncFile( const QUrl& outputUrl, QSet<QUrl>& nepomukUris, const QDateTime & min );
+ void createFirstSyncFile( const QUrl& outputUrl ) const;
private :
Identifier * m_identifier;
--- trunk/playground/base/nepomuk-kde/backupsync/service/syncrequest.cpp #1157989:1157990
@@ -253,6 +253,10 @@
if( n.isValid() ) {
kDebug() << "Adding : "<< n;
st.setObject( n );
+
+ // Slows down the merging, but it's worth it. This way we keep the original graph
+ // in the event that the statement exists.
+ if( !d->m_model->containsAnyStatement( st ) )
d->m_model->addStatement( st );
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic