Runtime: reset stale Core baseline on upgrade
This commit is contained in:
1 parent
978930f4d2
commit
2fba7d2dea
5 files changed
+310
-31
No files matched your search
+32
-29
@@ -17,7 +17,6 @@
|
||||
#include <Void/System/Process.hpp>
|
||||
#include <Void/System/SignalWatcher.hpp>
|
||||
#include <Void/TeamSpeak/Identity.hpp>
|
||||
#include <Void/Update/Update.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
@@ -245,30 +244,6 @@ namespace
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::filesystem::path
|
||||
reconcileManagedCore(const std::filesystem::path& stateDirectory,
|
||||
const std::filesystem::path& fallback)
|
||||
{
|
||||
Void::Update::VersionStore store(stateDirectory / "updates" /
|
||||
"components" / "core");
|
||||
if (auto initialized = store.initialize(); !initialized) {
|
||||
Void::Log::warn("main", "Cannot initialize managed Core store: {}",
|
||||
initialized.error().message());
|
||||
return fallback;
|
||||
}
|
||||
if (auto reconciled = store.reconcile(); !reconciled) {
|
||||
Void::Log::warn("main", "Cannot reconcile managed Core store: {}",
|
||||
reconciled.error().message());
|
||||
return fallback;
|
||||
}
|
||||
auto current = store.currentVersion();
|
||||
if (!current || !*current) {
|
||||
return fallback;
|
||||
}
|
||||
const auto managed = store.versionPath(**current) / fallback.filename();
|
||||
return std::filesystem::is_regular_file(managed) ? managed : fallback;
|
||||
}
|
||||
|
||||
[[nodiscard]] Echoion::Api::Result<std::string>
|
||||
invokeRuntimeHelper(const std::filesystem::path& helper,
|
||||
const std::filesystem::path& root,
|
||||
@@ -661,10 +636,38 @@ int main(int argc, char** argv)
|
||||
configuredCoreOverride &&
|
||||
absolutePath(*configuredCoreOverride) !=
|
||||
absolutePath(installRoot / "lib" / "Echoion.ts");
|
||||
const auto corePathResolved =
|
||||
customCoreOverride
|
||||
? configuredCorePath
|
||||
: reconcileManagedCore(stateDirectory, configuredCorePath);
|
||||
auto corePathResolved = configuredCorePath;
|
||||
if (!customCoreOverride) {
|
||||
const auto installedRuntimeVersion =
|
||||
runningManifest ? std::optional<std::string_view>{runtimeVersion}
|
||||
: std::nullopt;
|
||||
auto selection = Echoion::Standalone::selectManagedCoreForStartup(
|
||||
stateDirectory, configuredCorePath, installedRuntimeVersion);
|
||||
if (!selection) {
|
||||
Void::Log::warn(
|
||||
"main",
|
||||
"Cannot reconcile managed Core startup state; using the "
|
||||
"bundled Core: {}",
|
||||
selection.error().message);
|
||||
} else {
|
||||
corePathResolved = selection->corePath;
|
||||
if (selection->runtimeBaselineChanged) {
|
||||
if (selection->archivedStore) {
|
||||
Void::Log::info(
|
||||
"main",
|
||||
"Runtime {} selected its bundled Core and archived "
|
||||
"the previous managed Core store at {}",
|
||||
runtimeVersion,
|
||||
selection->archivedStore->string());
|
||||
} else {
|
||||
Void::Log::info(
|
||||
"main",
|
||||
"Runtime {} selected its bundled Core baseline",
|
||||
runtimeVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (const auto workingDirectory =
|
||||
Echoion::Standalone::runtimeWorkingDirectory(installRoot,
|
||||
executableDirectory)) {
|
||||
|
||||
Reference in new issue
Block a user