Cleanup active_runtime.json on start

This commit is contained in:
Patrick Nicolas
2026-06-17 22:01:51 +02:00
parent fc394dc3b9
commit 51e887ed1f
3 changed files with 20 additions and 0 deletions
+16
View File
@@ -238,4 +238,20 @@ active_runtime::~active_runtime()
std::cerr << "Cannot unset active OpenVR runtime: " << e.what() << std::endl;
}
}
void active_runtime::cleanup_openxr()
{
for (const auto & manifest: manifest_path())
{
auto active_runtime = xdg_config_home() / ("openxr/1/active_runtime" + get_abi(manifest) + ".json");
std::error_code ec;
if (std::filesystem::equivalent(manifest, active_runtime, ec))
{
std::cerr << "Removing stale file " << active_runtime << std::endl;
std::filesystem::remove(active_runtime, ec);
}
std::filesystem::rename(backup_name(manifest), manifest, ec);
}
}
} // namespace wivrn
+2
View File
@@ -39,5 +39,7 @@ public:
static std::vector<std::filesystem::path> manifest_path();
static std::filesystem::path openvr_compat_path();
static void cleanup_openxr();
};
} // namespace wivrn
+2
View File
@@ -949,6 +949,8 @@ int inner_main(int argc, char * argv[], bool show_instructions)
std::filesystem::create_directories(socket_path().parent_path());
if (do_active_runtime)
active_runtime::cleanup_openxr();
listen_socket = create_listen_socket();
u_trace_marker_init();