mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +01:00
ProfileManager: Avoid losing session when loading profile from newer app version
Backup session in session manager named "backup-$version". See #2520
This commit is contained in:
parent
825fc88c40
commit
7b0aa61975
|
@ -1,6 +1,6 @@
|
|||
/* ============================================================
|
||||
* Falkon - Qt web browser
|
||||
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2018 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -20,6 +20,7 @@
|
|||
#include "datapaths.h"
|
||||
#include "updater.h"
|
||||
#include "qztools.h"
|
||||
#include "restoremanager.h"
|
||||
|
||||
#include <QDir>
|
||||
#include <QSqlError>
|
||||
|
@ -182,6 +183,11 @@ void ProfileManager::updateProfile(const QString ¤t, const QString &profil
|
|||
|
||||
Updater::Version prof(profile);
|
||||
|
||||
if (prof > Updater::Version(Qz::VERSION)) {
|
||||
copyDataToProfile();
|
||||
return;
|
||||
}
|
||||
|
||||
if (prof < Updater::Version("1.9.0")) {
|
||||
std::cout << "Falkon: Using profile from QupZilla " << qPrintable(profile) << " is not supported!" << std::endl;
|
||||
return;
|
||||
|
@ -218,6 +224,17 @@ void ProfileManager::copyDataToProfile()
|
|||
settings.remove();
|
||||
}
|
||||
|
||||
QFile sessionFile(profileDir.filePath(QSL("session.dat")));
|
||||
if (sessionFile.exists() && !RestoreManager::validateFile(sessionFile.fileName())) {
|
||||
QString oldVersion = QzTools::readAllFileContents(profileDir.filePath(QSL("version"))).trimmed();
|
||||
if (oldVersion.isEmpty()) {
|
||||
oldVersion = QSL("unknown-version");
|
||||
}
|
||||
const QString sessionBackup = QzTools::ensureUniqueFilename(profileDir.filePath(QSL("sessions/backup-%1.dat").arg(oldVersion)));
|
||||
sessionFile.copy(sessionBackup);
|
||||
sessionFile.remove();
|
||||
}
|
||||
|
||||
const QString text = "Incompatible profile version has been detected. To avoid losing your profile data, they were "
|
||||
"backed up in following file:<br/><br/><b>" + browseDataBackup + "<br/></b>";
|
||||
QMessageBox::warning(0, "Falkon: Incompatible profile version", text);
|
||||
|
|
Loading…
Reference in New Issue
Block a user