SyncEngine: Calculate a uniq journal name using the remote account.

That should allow to sync the same local folder to multiple remote destinations.

see #3764
This commit is contained in:
Klaas Freitag 2016-07-10 12:56:43 +02:00
parent b9ea7c3414
commit 4ceee86c66
2 changed files with 13 additions and 8 deletions

View File

@ -90,8 +90,20 @@ SyncEngine::SyncEngine(AccountPtr account, const QString& localPath,
#endif
url_string = Utility::toCSyncScheme(url_string);
// localPath always has a trailing slash
QString dbFile = localPath;
dbFile.append( QLatin1String(".csync_"));
// FIXME: Make sure this remoteUrlPath is equal to the one calculated in FolderMan::ensureJournalGone
// FIXME: Maybe it is better to only allow different hosts, without path component.
QString remoteUrlPath = _remoteUrl.toString()+_remotePath;
QByteArray ba = QCryptographicHash::hash( remoteUrlPath.toUtf8(), QCryptographicHash::Md5);
dbFile.append( ba.left(6).toHex() );
_journal->setDatabaseFilePath(dbFile);
csync_create(&_csync_ctx, localPath.toUtf8().data(), url_string.toUtf8().data());
csync_init(_csync_ctx);
csync_init(_csync_ctx, dbFile.toUtf8().data());
_excludedFiles.reset(new ExcludedFiles(&_csync_ctx->excludes));
_syncFileStatusTracker.reset(new SyncFileStatusTracker(this));

View File

@ -33,13 +33,6 @@ SyncJournalDb::SyncJournalDb(const QString& path, QObject *parent) :
QObject(parent), _transaction(0)
{
_dbFile = path;
if( !_dbFile.endsWith('/') ) {
_dbFile.append('/');
}
_dbFile.append(".csync_journal.db");
}
bool SyncJournalDb::exists()