#include <QElapsedTimer>
#include <QUrl>
#include <QDir>
-#include <QStandardPaths>
#include <sqlite3.h>
#include "common/syncjournaldb.h"
}
}
-QString SyncJournalDb::makeDbName(const QUrl &remoteUrl,
+QString SyncJournalDb::makeDbName(const QString &localPath,
+ const QUrl &remoteUrl,
const QString &remotePath,
const QString &user)
{
- const QString dbPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
- if (!QDir(dbPath).exists()) {
- QDir().mkdir(dbPath);
- }
-
QString journalPath = QLatin1String("._sync_");
QString key = QString::fromUtf8("%1@%2:%3").arg(user, remoteUrl.toString(), remotePath);
journalPath.append(ba.left(6).toHex());
journalPath.append(".db");
- journalPath = dbPath + QLatin1Char('/') + journalPath;
-
// If the journal doesn't exist and we can't create a file
// at that location, try again with a journal name that doesn't
// have the ._ prefix.
//
+ // The disadvantage of that filename is that it will only be ignored
+ // by client versions >2.3.2.
+ //
// See #5633: "._*" is often forbidden on samba shared folders.
// If it exists already, the path is clearly usable
- QFile file(QDir(dbPath).filePath(journalPath));
+ QFile file(QDir(localPath).filePath(journalPath));
if (file.exists()) {
return journalPath;
}
// Can we create it if we drop the underscore?
QString alternateJournalPath = journalPath.mid(2).prepend(".");
- QFile file2(QDir(dbPath).filePath(alternateJournalPath));
+ QFile file2(QDir(localPath).filePath(alternateJournalPath));
if (file2.open(QIODevice::ReadWrite)) {
// The alternative worked, use it
qCInfo(lcDb) << "Using alternate database path" << alternateJournalPath;
virtual ~SyncJournalDb();
/// Create a journal path for a specific configuration
- static QString makeDbName(const QUrl &remoteUrl,
+ static QString makeDbName(const QString &localPath,
+ const QUrl &remoteUrl,
const QString &remotePath,
const QString &user);
QString FolderDefinition::defaultJournalPath(AccountPtr account)
{
- return SyncJournalDb::makeDbName(account->url(), targetPath, account->credentials()->user());
+ return SyncJournalDb::makeDbName(localPath, account->url(), targetPath, account->credentials()->user());
}
} // namespace OCC