MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / packageStampKey

Function packageStampKey

app/src/Misc/ModuleManager.cpp:404–452  ·  view source on GitHub ↗

* @brief Maps the CI-stamped ss-config.json (packageType + arch, shipped beside the executable) * to an appcast platform key; empty when the stamp is absent, unreadable, unknown or * stamped for a different platform (which must degrade, never offer a foreign package). */

Source from the content-addressed store, hash-verified

402 * stamped for a different platform (which must degrade, never offer a foreign package).
403 */
404[[nodiscard]] static QString packageStampKey()
405{
406 constexpr qint64 kMaxStampBytes = 4096;
407
408 QStringList candidates = {QCoreApplication::applicationDirPath()
409 + QStringLiteral("/ss-config.json")};
410#if defined(Q_OS_MACOS)
411 candidates.append(QCoreApplication::applicationDirPath()
412 + QStringLiteral("/../Resources/ss-config.json"));
413#endif
414
415 for (const auto& path : std::as_const(candidates)) {
416 QFile file(path);
417 if (file.size() > kMaxStampBytes || !file.open(QIODevice::ReadOnly))
418 continue;
419
420 const auto stamp = QJsonDocument::fromJson(file.readAll()).object();
421 const auto type = stamp.value(QStringLiteral("packageType")).toString();
422
423#if defined(Q_OS_WIN)
424 if (type == QStringLiteral("msi"))
425 return QStringLiteral("windows-msi");
426
427 if (type == QStringLiteral("portable"))
428 return QStringLiteral("windows-portable");
429
430 if (type == QStringLiteral("msix"))
431 return QStringLiteral("windows-msix");
432#elif defined(Q_OS_MACOS)
433 if (type == QStringLiteral("dmg"))
434 return QStringLiteral("osx-dmg");
435#elif defined(Q_OS_LINUX)
436 const auto arch = stamp.value(QStringLiteral("arch")).toString();
437
438 QString suffix;
439 if (arch == QStringLiteral("x86_64"))
440 suffix = QStringLiteral("x64");
441 else if (arch == QStringLiteral("arm64"))
442 suffix = QStringLiteral("arm64");
443
444 const bool linux_type = (type == QStringLiteral("appimage") || type == QStringLiteral("deb")
445 || type == QStringLiteral("rpm"));
446 if (linux_type && !suffix.isEmpty())
447 return QStringLiteral("linux-%1-%2").arg(type, suffix);
448#endif
449 }
450
451 return QString();
452}
453
454/**
455 * @brief Detects the packaging at runtime when no stamp resolved: the AppImage runtime

Callers 1

configureUpdaterMethod · 0.85

Calls 6

fromJsonFunction · 0.85
isEmptyMethod · 0.80
appendMethod · 0.45
sizeMethod · 0.45
openMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected