Skip to content

Commit 2487529

Browse files
committed
Migrate existing db files and save their journal path
Fixes: #9019
1 parent 5f67ba8 commit 2487529

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

changelog/unreleased/9019

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Bugfix: A upgrade to 2.9 causes the usage of a new journal file
2+
3+
We fixed a bug where the name of the sync journal was not properly saved to the settings.
4+
This caused a bug when migration to 2.9 to start with a new sync journal.
5+
6+
This not only caused the loss of some selective sync settings, but also caused the display of the
7+
8+
```
9+
Multiple accounts are sharing the folder.
10+
This configuration is know to lead to dataloss and is no longer supported.
11+
Please consider removing this folder from the account and adding it again.
12+
```
13+
14+
message.

src/common/syncjournaldb.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class OCSYNC_EXPORT SyncJournalDb : public QObject
5050

5151
/// Create a journal path for a specific configuration
5252
static QString makeDbName(const QString &localPath,
53-
const QString &infix);
53+
const QString &infix = QStringLiteral("journal"));
5454

5555
static QString makeDbName(const QString &localPath,
5656
const QUrl &remoteUrl,

src/gui/folder.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -1338,9 +1338,4 @@ QString FolderDefinition::absoluteJournalPath() const
13381338
return QDir(localPath).filePath(journalPath);
13391339
}
13401340

1341-
QString FolderDefinition::defaultJournalPath(AccountPtr account)
1342-
{
1343-
return SyncJournalDb::makeDbName(localPath, QStringLiteral("journal"));
1344-
}
1345-
13461341
} // namespace OCC

src/gui/folder.h

-3
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ class FolderDefinition
101101

102102
/// journalPath relative to localPath.
103103
QString absoluteJournalPath() const;
104-
105-
/// Returns the relative journal path that's appropriate for this folder and account.
106-
QString defaultJournalPath(AccountPtr account);
107104
};
108105

109106
/**

src/gui/folderman.cpp

+14-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,16 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
286286
FolderDefinition folderDefinition;
287287
settings.beginGroup(folderAlias);
288288
if (FolderDefinition::load(settings, folderAlias, &folderDefinition)) {
289-
auto defaultJournalPath = folderDefinition.defaultJournalPath(account->account());
289+
const auto defaultJournalPath = [&account, folderDefinition] {
290+
// if we would have booth the 2.9.0 file name and the lagacy file
291+
// with the md5 infix we prefer the 2.9.0 version
292+
const auto path = SyncJournalDb::makeDbName(folderDefinition.localPath);
293+
if (QFileInfo::exists(QDir(folderDefinition.localPath).filePath(path))) {
294+
return path;
295+
}
296+
// legacy name
297+
return SyncJournalDb::makeDbName(folderDefinition.localPath, account->account()->url(), folderDefinition.targetPath, account->account()->credentials()->user());
298+
}();
290299

291300
// Migration: Old settings don't have journalPath
292301
if (folderDefinition.journalPath.isEmpty()) {
@@ -329,6 +338,9 @@ void FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account,
329338
if (foldersWithPlaceholders)
330339
f->setSaveInFoldersWithPlaceholders();
331340

341+
// save possible changes from the migration
342+
f->saveToSettings();
343+
332344
scheduleFolder(f);
333345
emit folderSyncStateChange(f);
334346
}
@@ -1011,7 +1023,7 @@ Folder *FolderMan::addFolder(AccountState *accountState, const FolderDefinition
10111023
{
10121024
// Choose a db filename
10131025
auto definition = folderDefinition;
1014-
definition.journalPath = definition.defaultJournalPath(accountState->account());
1026+
definition.journalPath = SyncJournalDb::makeDbName(folderDefinition.localPath);
10151027

10161028
if (!ensureJournalGone(definition.absoluteJournalPath())) {
10171029
return nullptr;

0 commit comments

Comments
 (0)