Manager: Fix UUID generation for manager config headers

Fix different UUIDs generating depending on the whether the path
is absolute or relative; they now always match the ones saved
inside .cfg files
Also reduce some code duplication
This commit is contained in:
Alexander Babikov
2025-07-28 20:25:20 +05:00
parent 494a24a3ae
commit dca59145f6
3 changed files with 13 additions and 12 deletions

View File

@@ -117,11 +117,16 @@ DlgFilter(QStringList extensions, bool last)
QString currentUuid()
{
auto configPath = QFileInfo(cfg_path).dir().canonicalPath();
if(!configPath.endsWith("/")) {
configPath.append("/");
return generateUuid(QString(cfg_path));
}
QString generateUuid(const QString &path)
{
auto dirPath = QFileInfo(path).dir().canonicalPath();
if(!dirPath.endsWith("/")) {
dirPath.append("/");
}
return QUuid::createUuidV5(QUuid{}, configPath).toString(QUuid::WithoutBraces);
return QUuid::createUuidV5(QUuid{}, dirPath).toString(QUuid::WithoutBraces);
}
bool compareUuid()

View File

@@ -18,6 +18,7 @@ QScreen *screenOfWidget(QWidget *widget);
void setWin11RoundedCorners(WId hwnd, bool enable);
#endif
QString currentUuid();
QString generateUuid(const QString &path);
void storeCurrentUuid();
bool compareUuid();
void generateNewMacAdresses();

View File

@@ -28,6 +28,7 @@
#include <QElapsedTimer>
#include <QProgressDialog>
#include <QWindow>
#include "qt_util.hpp"
#include "qt_vmmanager_system.hpp"
// #include "qt_vmmanager_details_section.hpp"
#include "qt_vmmanager_detailsection.hpp"
@@ -67,16 +68,10 @@ VMManagerSystem::VMManagerSystem(const QString &sysconfig_file) {
// that contains the 86box configuration file
config_name = config_file.dir().dirName();
// The full path of the directory that contains the 86box configuration file
config_dir = shortened_dir = config_file.dir().path();
config_dir = shortened_dir = config_file.dir().absolutePath();
process_status = ProcessStatus::Stopped;
// Main 86Box uses usr_path for UUID which includes the trailing slash.
// Make sure to append the slash here so the UUIDs will match
auto uuid_path = config_dir;
if (!uuid_path.endsWith("/")) {
uuid_path.append("/");
}
// In the configuration file the UUID is used as a unique value
uuid = QUuid::createUuidV5(QUuid{}, uuid_path).toString(QUuid::WithoutBraces);
uuid = util::generateUuid(sysconfig_file);
// That unique value is used to map the information to each individual system.
config_settings = new VMManagerConfig(VMManagerConfig::ConfigType::System, uuid);