Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schuster <48932272+misch7@users.noreply.github.com>2019-10-27 20:03:49 +0300
committerGitHub <noreply@github.com>2019-10-27 20:03:49 +0300
commita15cad00887b3c05a3aa303533778927948ca418 (patch)
treee6648091b2fef14a056c3b144ae822f2b52685c8
parent528352ba829d128e58efb80f5dd301889736350d (diff)
parent8e8858178b140364019233a62a81af1970fab8a8 (diff)
Merge pull request #1451 from nextcloud/move-rtfiles
Move journal files away from sync folder to standardized location
-rw-r--r--src/cmd/cmd.cpp2
-rw-r--r--src/common/syncjournaldb.cpp18
-rw-r--r--src/common/syncjournaldb.h3
-rw-r--r--src/gui/folder.cpp2
-rw-r--r--src/gui/folder.h2
-rw-r--r--src/gui/folderman.cpp21
6 files changed, 36 insertions, 12 deletions
diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp
index 5e3517af2..47876b231 100644
--- a/src/cmd/cmd.cpp
+++ b/src/cmd/cmd.cpp
@@ -499,7 +499,7 @@ restart_sync:
}
Cmd cmd;
- QString dbPath = options.source_dir + SyncJournalDb::makeDbName(options.source_dir, credentialFreeUrl, folder, user);
+ QString dbPath = options.source_dir + SyncJournalDb::makeDbName(credentialFreeUrl, folder, user);
SyncJournalDb db(dbPath);
if (!selectiveSyncList.empty()) {
diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp
index d81cb865b..e4078efd9 100644
--- a/src/common/syncjournaldb.cpp
+++ b/src/common/syncjournaldb.cpp
@@ -23,6 +23,7 @@
#include <QElapsedTimer>
#include <QUrl>
#include <QDir>
+#include <QStandardPaths>
#include <sqlite3.h>
#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 c8d0e645b..64b40fa69 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;
diff --git a/src/gui/folderman.cpp b/src/gui/folderman.cpp
index af4526545..88b112928 100644
--- a/src/gui/folderman.cpp
+++ b/src/gui/folderman.cpp
@@ -210,6 +210,27 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
folderDefinition.journalPath = defaultJournalPath;
}
+ // Migration #2: journalPath now in DataAppDir, not root of local tree (cross-platform persistent user roaming files)
+ if (folderDefinition.journalPath.at(0) == QChar('.')) {
+ QFile oldJournal(folderDefinition.localPath + "/" + folderDefinition.journalPath);
+ QFile oldJournalShm(folderDefinition.localPath + "/" + folderDefinition.journalPath.append("-shm"));
+ QFile oldJournalWal(folderDefinition.localPath + "/" + folderDefinition.journalPath.append("-wal"));
+
+ folderDefinition.journalPath = defaultJournalPath;
+
+ socketApi()->slotUnregisterPath(folderAlias);
+ auto settings = account->settings();
+
+ Folder *f = addFolderInternal(folderDefinition, account.data());
+ f->saveToSettings();
+
+ oldJournal.remove();
+ oldJournalShm.remove();
+ oldJournalWal.remove();
+
+ return;
+ }
+
// Migration: ._ files sometimes don't work
// So if the configured journalPath is the default one ("._sync_*.db")
// but the current default doesn't have the underscore, switch to the