From: Kevin Ottens Date: Thu, 5 Nov 2020 14:27:27 +0000 (+0100) Subject: Revert "moved default db sync file to Qt standard path AppDataLocation" X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~22^2~66^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0b731eb516923962cd2ff92e0c3a616bff2eb147;p=nextcloud-desktop.git Revert "moved default db sync file to Qt standard path AppDataLocation" This reverts commit fc6b895f524cfadd7edff83098c70d7cc44248a9. Signed-off-by: Kevin Ottens --- diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp index 83da1d4cc..7a6bee7e9 100644 --- a/src/common/syncjournaldb.cpp +++ b/src/common/syncjournaldb.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include "common/syncjournaldb.h" @@ -104,15 +103,11 @@ SyncJournalDb::SyncJournalDb(const QString &dbFilePath, QObject *parent) } } -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); @@ -121,16 +116,17 @@ QString SyncJournalDb::makeDbName(const QUrl &remoteUrl, 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; } @@ -145,7 +141,7 @@ QString SyncJournalDb::makeDbName(const QUrl &remoteUrl, // 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; diff --git a/src/common/syncjournaldb.h b/src/common/syncjournaldb.h index 17eb8dee6..de93bdc5e 100644 --- a/src/common/syncjournaldb.h +++ b/src/common/syncjournaldb.h @@ -46,7 +46,8 @@ public: 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); diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index b047d7f85..2a1319d2c 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -1204,7 +1204,7 @@ QString FolderDefinition::absoluteJournalPath() const 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 diff --git a/src/gui/folder.h b/src/gui/folder.h index 72c651b73..6f6423b7a 100644 --- a/src/gui/folder.h +++ b/src/gui/folder.h @@ -51,7 +51,7 @@ public: QString alias; /// path on local machine QString localPath; - /// path to the journal, usually in QStandardPaths::AppDataLocation + /// path to the journal, usually relative to localPath QString journalPath; /// path on remote QString targetPath;