From fc6b895f524cfadd7edff83098c70d7cc44248a9 Mon Sep 17 00:00:00 2001 From: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> Date: Thu, 26 Sep 2019 17:09:24 +0200 Subject: [PATCH] moved default db sync file to Qt standard path AppDataLocation Signed-off-by: Dominique Fuchs <32204802+DominiqueFuchs@users.noreply.github.com> --- src/common/syncjournaldb.cpp | 18 +++++++++++------- src/common/syncjournaldb.h | 3 +-- src/gui/folder.cpp | 2 +- src/gui/folder.h | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index d81cb865b..3c10c7123 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "common/syncjournaldb.h" @@ -102,11 +103,15 @@ SyncJournalDb::SyncJournalDb(const QString &dbFilePath, QObject *parent) } } -QString SyncJournalDb::makeDbName(const QString &localPath, - const QUrl &remoteUrl, +QString SyncJournalDb::makeDbName(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); @@ -115,17 +120,16 @@ QString SyncJournalDb::makeDbName(const QString &localPath, 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(localPath).filePath(journalPath)); + QFile file(QDir(dbPath).filePath(journalPath)); if (file.exists()) { return journalPath; } @@ -140,7 +144,7 @@ QString SyncJournalDb::makeDbName(const QString &localPath, // Can we create it if we drop the underscore? QString alternateJournalPath = journalPath.mid(2).prepend("."); - QFile file2(QDir(localPath).filePath(alternateJournalPath)); + QFile file2(QDir(dbPath).filePath(alternateJournalPath)); if (file2.open(QIODevice::ReadWrite)) { // The alternative worked, use it qCInfo(lcDb) << "Using alternate database path" << alternateJournalPath; diff --git a/src/common/syncjournaldb.h b/src/common/syncjournaldb.h index d8ebeab75..4d09aa844 100644 --- a/src/common/syncjournaldb.h +++ b/src/common/syncjournaldb.h @@ -46,8 +46,7 @@ public: virtual ~SyncJournalDb(); /// Create a journal path for a specific configuration - static QString makeDbName(const QString &localPath, - const QUrl &remoteUrl, + static QString makeDbName(const QUrl &remoteUrl, const QString &remotePath, const QString &user); diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 2d83cae44..f152c8992 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -1198,7 +1198,7 @@ QString FolderDefinition::absoluteJournalPath() const QString FolderDefinition::defaultJournalPath(AccountPtr account) { - return SyncJournalDb::makeDbName(localPath, account->url(), targetPath, account->credentials()->user()); + return SyncJournalDb::makeDbName(account->url(), targetPath, account->credentials()->user()); } } // namespace OCC diff --git a/src/gui/folder.h b/src/gui/folder.h index 48a2e52f7..b16bba5cd 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -57,7 +57,7 @@ public: QString alias; /// path on local machine QString localPath; - /// path to the journal, usually relative to localPath + /// path to the journal, usually in QStandardPaths::AppDataLocation QString journalPath; /// path on remote QString targetPath; -- 2.30.2