mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-20 11:03:56 +00:00
updater: Improve version detection with build system fallback
Add build system version detection as a fallback in GetCurrentVersion(): - Include common/scm_rev.h to access build version information - Use Common::g_build_version when version.txt doesn't exist - Automatically create version.txt with build version for future use - Update comments to clarify version resolution priority This ensures the updater can properly detect the current application version even when version.txt hasn't been created yet, while maintaining the existing priority system for version detection. Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
#include "citron/updater/updater_service.h"
|
#include "citron/updater/updater_service.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "common/fs/path_util.h"
|
#include "common/fs/path_util.h"
|
||||||
|
#include "common/scm_rev.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
@@ -360,7 +361,7 @@ void UpdaterService::CancelUpdate() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::string UpdaterService::GetCurrentVersion() const {
|
std::string UpdaterService::GetCurrentVersion() const {
|
||||||
// Try to read version from version.txt file
|
// Try to read version from version.txt file first (updated versions)
|
||||||
std::filesystem::path version_file = app_directory / CITRON_VERSION_FILE;
|
std::filesystem::path version_file = app_directory / CITRON_VERSION_FILE;
|
||||||
|
|
||||||
if (std::filesystem::exists(version_file)) {
|
if (std::filesystem::exists(version_file)) {
|
||||||
@@ -374,7 +375,24 @@ std::string UpdaterService::GetCurrentVersion() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fallback to application version
|
// Use build version from the build system
|
||||||
|
std::string build_version = Common::g_build_version;
|
||||||
|
if (!build_version.empty()) {
|
||||||
|
// Create version.txt file if it doesn't exist
|
||||||
|
try {
|
||||||
|
std::ofstream vfile(version_file);
|
||||||
|
if (vfile.is_open()) {
|
||||||
|
vfile << build_version;
|
||||||
|
vfile.close();
|
||||||
|
LOG_INFO(Frontend, "Created version.txt with build version: {}", build_version);
|
||||||
|
}
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
LOG_WARNING(Frontend, "Failed to create version.txt: {}", e.what());
|
||||||
|
}
|
||||||
|
return build_version;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Final fallback to application version
|
||||||
return QCoreApplication::applicationVersion().toStdString();
|
return QCoreApplication::applicationVersion().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user