From 72527fae80bcf16fdf03890a66af65ac831fe18a Mon Sep 17 00:00:00 2001 From: E <2974895+eduardomozart@users.noreply.github.com> Date: Fri, 14 Aug 2026 18:57:40 -0300 Subject: [PATCH 1/2] Fix: Dynamically reload apps.json for Moonlight API if modified on disk This adds a timestamp check in proc::refresh() and calls it from the /applist endpoint to ensure changes made to apps.json outside the Web UI are immediately reflected in Moonlight. --- src/nvhttp.cpp | 1 + src/process.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index e260141a7d7..faaf946c7c0 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -955,6 +955,7 @@ namespace nvhttp { */ void applist(resp_https_t response, req_https_t request) { print_req(request); + proc::refresh(config::stream.file_apps); pt::ptree tree; diff --git a/src/process.cpp b/src/process.cpp index ca4b50d5552..2cf00bf205c 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -45,6 +45,8 @@ namespace proc { proc_t proc; ///< Global process registry used to track and terminate child processes. + std::filesystem::file_time_type last_apps_file_update; ///< Timestamp of the last time apps.json was parsed. + /** * @brief RAII helper that runs shutdown cleanup when destroyed. */ @@ -794,12 +796,25 @@ namespace proc { /** * @brief Refresh cached platform state from the operating system. + * + * This function compares the current last modified time of the file to the time it was last parsed. + * If the file has been modified since it was last parsed (or if it has never been parsed), + * it will be re-parsed to update the app list. */ void refresh(const std::string &file_name) { + std::error_code ec; + auto current_time = std::filesystem::last_write_time(file_name, ec); + + // Only parse the file if there were no errors reading the timestamp and it has been updated + if (!ec && current_time <= last_apps_file_update) { + return; + } + auto proc_opt = proc::parse(file_name); if (proc_opt) { proc = std::move(*proc_opt); + last_apps_file_update = current_time; } } } // namespace proc From 9f01397718beb3ae73889aa773c5e6017778c984 Mon Sep 17 00:00:00 2001 From: E <2974895+eduardomozart@users.noreply.github.com> Date: Fri, 14 Aug 2026 18:57:40 -0300 Subject: [PATCH 2/2] Fix: Dynamically reload apps.json for Moonlight API if modified on disk This adds a timestamp check in proc::refresh() and calls it from the /applist endpoint to ensure changes made to apps.json outside the Web UI are immediately reflected in Moonlight. --- src/nvhttp.cpp | 1 + src/process.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/nvhttp.cpp b/src/nvhttp.cpp index e260141a7d7..faaf946c7c0 100644 --- a/src/nvhttp.cpp +++ b/src/nvhttp.cpp @@ -955,6 +955,7 @@ namespace nvhttp { */ void applist(resp_https_t response, req_https_t request) { print_req(request); + proc::refresh(config::stream.file_apps); pt::ptree tree; diff --git a/src/process.cpp b/src/process.cpp index ca4b50d5552..34dfe9c7b05 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -794,12 +794,27 @@ namespace proc { /** * @brief Refresh cached platform state from the operating system. + * + * This function compares the current last modified time of the file to the time it was last parsed. + * If the file has been modified since it was last parsed (or if it has never been parsed), + * it will be re-parsed to update the app list. */ void refresh(const std::string &file_name) { + static std::filesystem::file_time_type last_apps_file_update; ///< Timestamp of the last time apps.json was parsed. + + std::error_code ec; + auto current_time = std::filesystem::last_write_time(file_name, ec); + + // Only parse the file if there were no errors reading the timestamp and it has been updated + if (!ec && current_time <= last_apps_file_update) { + return; + } + auto proc_opt = proc::parse(file_name); if (proc_opt) { proc = std::move(*proc_opt); + last_apps_file_update = current_time; } } } // namespace proc