Revert "moved default db sync file to Qt standard path AppDataLocation"
authorKevin Ottens <kevin.ottens@nextcloud.com>
Thu, 5 Nov 2020 14:27:27 +0000 (15:27 +0100)
committerKevin Ottens (Rebase PR Action) <er-vin@users.noreply.github.com>
Tue, 10 Nov 2020 17:46:43 +0000 (17:46 +0000)
This reverts commit fc6b895f524cfadd7edff83098c70d7cc44248a9.

Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
src/common/syncjournaldb.cpp
src/common/syncjournaldb.h
src/gui/folder.cpp
src/gui/folder.h

index 83da1d4cc4accda73d212e42e6f7213f635eb423..7a6bee7e9de5bd8fb53559fc3dea60a5b060c839 100644 (file)
@@ -23,7 +23,6 @@
 #include <QElapsedTimer>
 #include <QUrl>
 #include <QDir>
-#include <QStandardPaths>
 #include <sqlite3.h>
 
 #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;
index 17eb8dee64eab0f15b0ff0b0c7a0dd7b41e06ac5..de93bdc5e3d170fbf35ded9058588608b1689d1c 100644 (file)
@@ -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);
 
index b047d7f85b5dbf4c136c70d0f7365b140f9b009d..2a1319d2c65677b157266ffefebe958ac1d08bc0 100644 (file)
@@ -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
index 72c651b735d22136d6f6708f037802039458e2f8..6f6423b7a948c14c463a7abe9ad372ea6e3751c2 100644 (file)
@@ -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;