Skip to content

Commit

Permalink
Remove migration of old db files
Browse files Browse the repository at this point in the history
Remove the migration of sync database files older than 6 years.
  • Loading branch information
erikjv committed Sep 29, 2023
1 parent 43e6fc3 commit 4f30ba6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 66 deletions.
61 changes: 0 additions & 61 deletions src/common/syncjournaldb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,67 +131,6 @@ QString SyncJournalDb::makeDbName(const QString &localPath,
return journalPath;
}

bool SyncJournalDb::maybeMigrateDb(const QString &localPath, const QString &absoluteJournalPath)
{
const QString oldDbName = localPath + QLatin1String(".csync_journal.db");
if (!FileSystem::fileExists(oldDbName)) {
return true;
}
const QString oldDbNameShm = oldDbName + QStringLiteral("-shm");
const QString oldDbNameWal = oldDbName + QStringLiteral("-wal");

const QString newDbName = absoluteJournalPath;
const QString newDbNameShm = newDbName + QStringLiteral("-shm");
const QString newDbNameWal = newDbName + QStringLiteral("-wal");

// Whenever there is an old db file, migrate it to the new db path.
// This is done to make switching from older versions to newer versions
// work correctly even if the user had previously used a new version
// and therefore already has an (outdated) new-style db file.
QString error;

if (FileSystem::fileExists(newDbName)) {
if (!FileSystem::remove(newDbName, &error)) {
qCWarning(lcDb) << "Database migration: Could not remove db file" << newDbName
<< "due to" << error;
return false;
}
}
if (FileSystem::fileExists(newDbNameWal)) {
if (!FileSystem::remove(newDbNameWal, &error)) {
qCWarning(lcDb) << "Database migration: Could not remove db WAL file" << newDbNameWal
<< "due to" << error;
return false;
}
}
if (FileSystem::fileExists(newDbNameShm)) {
if (!FileSystem::remove(newDbNameShm, &error)) {
qCWarning(lcDb) << "Database migration: Could not remove db SHM file" << newDbNameShm
<< "due to" << error;
return false;
}
}

if (!FileSystem::rename(oldDbName, newDbName, &error)) {
qCWarning(lcDb) << "Database migration: could not rename" << oldDbName
<< "to" << newDbName << ":" << error;
return false;
}
if (!FileSystem::rename(oldDbNameWal, newDbNameWal, &error)) {
qCWarning(lcDb) << "Database migration: could not rename" << oldDbNameWal
<< "to" << newDbNameWal << ":" << error;
return false;
}
if (!FileSystem::rename(oldDbNameShm, newDbNameShm, &error)) {
qCWarning(lcDb) << "Database migration: could not rename" << oldDbNameShm
<< "to" << newDbNameShm << ":" << error;
return false;
}

qCInfo(lcDb) << "Journal successfully migrated from" << oldDbName << "to" << newDbName;
return true;
}

bool SyncJournalDb::dbIsTooNewForClient(const QString &dbFilePath)
{
SqlDatabase db;
Expand Down
3 changes: 0 additions & 3 deletions src/common/syncjournaldb.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ class OCSYNC_EXPORT SyncJournalDb : public QObject
static QString makeDbName(const QString &localPath,
const QString &infix = QStringLiteral("journal"));

/// Migrate a csync_journal to the new path, if necessary. Returns false on error
static bool maybeMigrateDb(const QString &localPath, const QString &absoluteJournalPath);

static bool dbIsTooNewForClient(const QString &dbFilePath);

// To verify that the record could be found check with SyncJournalFileRecord::isValid()
Expand Down
2 changes: 0 additions & 2 deletions src/gui/folderman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,6 @@ bool FolderMan::setupFoldersHelper(QSettings &settings, AccountStatePtr account)
folderDefinition.journalPath = defaultJournalPath;
}

// Migration: If an old .csync_journal.db is found, move it to the new name.
SyncJournalDb::maybeMigrateDb(folderDefinition.localPath(), folderDefinition.absoluteJournalPath());
if (SyncJournalDb::dbIsTooNewForClient(folderDefinition.absoluteJournalPath())) {
return false;
}
Expand Down

0 comments on commit 4f30ba6

Please sign in to comment.