зеркало из https://github.com/nextcloud/desktop.git
Move the journal file name generation to the syncjournaldb class.
As requested by Olivier.
This commit is contained in:
Родитель
5d13f9290f
Коммит
e1a48e3c33
|
@ -80,6 +80,7 @@ Folder::Folder(const FolderDefinition& definition,
|
|||
checkLocalPath();
|
||||
|
||||
_syncResult.setFolder(_definition.alias);
|
||||
_journal.setAccountParameterForFilePath(path(), remoteUrl(), remotePath());
|
||||
|
||||
_engine.reset(new SyncEngine(_accountState->account(), path(), remoteUrl(), remotePath(), &_journal));
|
||||
// pass the setting if hidden files are to be ignored, will be read in csync_update
|
||||
|
|
|
@ -92,9 +92,7 @@ SyncEngine::SyncEngine(AccountPtr account, const QString& localPath,
|
|||
|
||||
csync_create(&_csync_ctx, localPath.toUtf8().data(), url_string.toUtf8().data());
|
||||
|
||||
const QString dbFile = this->journalDbFilePath();
|
||||
_journal->setDatabaseFilePath( dbFile );
|
||||
Q_ASSERT(!dbFile.isEmpty());
|
||||
const QString dbFile = _journal->databaseFilePath();
|
||||
csync_init(_csync_ctx, dbFile.toUtf8().data());
|
||||
|
||||
_excludedFiles.reset(new ExcludedFiles(&_csync_ctx->excludes));
|
||||
|
@ -116,23 +114,6 @@ SyncEngine::~SyncEngine()
|
|||
csync_destroy(_csync_ctx);
|
||||
}
|
||||
|
||||
QString SyncEngine::journalDbFilePath() const
|
||||
{
|
||||
// localPath always has a trailing slash
|
||||
QString dbFile(_localPath);
|
||||
dbFile.append( QLatin1String(".sync_"));
|
||||
// FIXME: Maybe it is better to only allow different hosts, without path component.
|
||||
QString remoteUrlPath = _remoteUrl.toString();
|
||||
if( _remotePath != QLatin1String("/") ) {
|
||||
remoteUrlPath.append(_remotePath);
|
||||
}
|
||||
QByteArray ba = QCryptographicHash::hash( remoteUrlPath.toUtf8(), QCryptographicHash::Md5);
|
||||
dbFile.append( ba.left(6).toHex() );
|
||||
dbFile.append(".db");
|
||||
|
||||
return dbFile;
|
||||
}
|
||||
|
||||
//Convert an error code from csync to a user readable string.
|
||||
// Keep that function thread safe as it can be called from the sync thread or the main thread
|
||||
QString SyncEngine::csyncErrorToString(CSYNC_STATUS err)
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <QStringList>
|
||||
#include <QDebug>
|
||||
#include <QElapsedTimer>
|
||||
#include <QUrl>
|
||||
|
||||
#include "ownsql.h"
|
||||
|
||||
|
@ -42,11 +43,27 @@ bool SyncJournalDb::exists()
|
|||
return (!_dbFile.isEmpty() && QFile::exists(_dbFile));
|
||||
}
|
||||
|
||||
void SyncJournalDb::setAccountParameterForFilePath( const QString& localPath, const QUrl& remoteUrl, const QString& remotePath )
|
||||
{
|
||||
// localPath always has a trailing slash
|
||||
_dbFile = localPath;
|
||||
_dbFile.append( QLatin1String(".sync_"));
|
||||
// FIXME: Maybe it is better to only allow different hosts, without path component.
|
||||
QString remoteUrlPath = remoteUrl.toString();
|
||||
if( remotePath != QLatin1String("/") ) {
|
||||
remoteUrlPath.append(remotePath);
|
||||
}
|
||||
QByteArray ba = QCryptographicHash::hash( remoteUrlPath.toUtf8(), QCryptographicHash::Md5);
|
||||
_dbFile.append( ba.left(6).toHex() );
|
||||
_dbFile.append(".db");
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void SyncJournalDb::setDatabaseFilePath( const QString& dbFile)
|
||||
{
|
||||
_dbFile = dbFile;
|
||||
}
|
||||
|
||||
#endif
|
||||
QString SyncJournalDb::databaseFilePath()
|
||||
{
|
||||
return _dbFile;
|
||||
|
|
|
@ -56,7 +56,10 @@ public:
|
|||
void walCheckpoint();
|
||||
|
||||
QString databaseFilePath();
|
||||
#ifndef NDEBUG
|
||||
void setDatabaseFilePath( const QString& dbFile);
|
||||
#endif
|
||||
void setAccountParameterForFilePath(const QString& localPath, const QUrl &remoteUrl, const QString& remotePath );
|
||||
|
||||
static qint64 getPHash(const QString& );
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче