void ProfileManager::updateCurrentProfile() { QDir profileDir(DataPaths::currentProfilePath()); if (!profileDir.exists()) { QDir newDir(profileDir.path().remove(profileDir.dirName())); newDir.mkdir(profileDir.dirName()); } QFile versionFile(profileDir.filePath(QLatin1String("version"))); // If file exists, just update the profile to current version if (versionFile.exists()) { versionFile.open(QFile::ReadOnly); QString profileVersion = versionFile.readAll(); versionFile.close(); updateProfile(Qz::VERSION, profileVersion.trimmed()); } else { copyDataToProfile(); } versionFile.open(QFile::WriteOnly); versionFile.write(Qz::VERSION); versionFile.close(); }
void ProfileUpdater::checkProfile() { QDir profileDir(m_profilePath); if (!profileDir.exists()) { QDir newDir(profileDir.path().remove(profileDir.dirName())); newDir.mkdir(profileDir.dirName()); } QFile versionFile(m_profilePath + "version"); if (versionFile.exists()) { versionFile.open(QFile::ReadOnly); QString profileVersion = versionFile.readAll(); versionFile.close(); versionFile.remove(); updateProfile(QupZilla::VERSION, profileVersion.trimmed()); } else { copyDataToProfile(); } versionFile.open(QFile::WriteOnly); versionFile.write(QupZilla::VERSION.toUtf8()); versionFile.close(); }
void ProfileUpdater::updateProfile(const QString ¤t, const QString &profile) { if (current == profile) { return; } // Updater::Version currentVersion = Updater::parseVersionFromString(current); Updater::Version profileVersion = Updater::parseVersionFromString(profile); if (profileVersion == Updater::parseVersionFromString("1.0.0-b4")) { update100b4(); update100rc1(); update100(); update118(); return; } if (profileVersion == Updater::parseVersionFromString("1.0.0-rc1")) { update100rc1(); update100(); update118(); return; } if (profileVersion == Updater::parseVersionFromString("1.0.0")) { update100(); update118(); return; } if (profileVersion == Updater::parseVersionFromString("1.1.0")) { // Do nothing, nothing changed return; } if (profileVersion == Updater::parseVersionFromString("1.1.5")) { // Do nothing, nothing changed return; } if (profileVersion == Updater::parseVersionFromString("1.1.8")) { update118(); return; } std::cout << "QupZilla: Incompatible profile version detected, overwriting profile data..." << std::endl; copyDataToProfile(); }
void ProfileManager::updateProfile(const QString ¤t, const QString &profile) { if (current == profile) { return; } Updater::Version prof(profile); if (prof == Updater::Version("1.0.0")) { update100(); return; } if (prof == Updater::Version("1.1.0") || prof == Updater::Version("1.1.5") || prof == Updater::Version("1.1.8")) { update118(); return; } if (prof == Updater::Version("1.2.0")) { update120(); return; } if (prof == Updater::Version("1.3.0") || prof == Updater::Version("1.3.1")) { update130(); return; } if (prof >= Updater::Version("1.4.0") && prof <= Updater::Version("1.5.0")) { update140(); return; } if (prof >= Updater::Version("1.6.0") && prof < Updater::Version("1.8.0")) { update160(); return; } if (prof >= Updater::Version("1.8.0") && prof < Updater::Version("1.9.0")) { // do nothing return; } std::cout << "QupZilla: Incompatible profile version detected (" << qPrintable(profile) << "), overwriting profile data..." << std::endl; copyDataToProfile(); }