From 988bf33b40ede3513200090207572681533091e0 Mon Sep 17 00:00:00 2001 From: loki Date: Thu, 10 Jun 2021 17:44:40 +0200 Subject: [PATCH] Fix bug not accepting paired device after reboot --- sunshine/nvhttp.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/sunshine/nvhttp.cpp b/sunshine/nvhttp.cpp index b425ea4e..f96c7a80 100644 --- a/sunshine/nvhttp.cpp +++ b/sunshine/nvhttp.cpp @@ -98,7 +98,7 @@ void save_state() { pt::read_json(config::nvhttp.file_state, root); } catch(std::exception &e) { - BOOST_LOG(error) << e.what(); + BOOST_LOG(error) << "Couldn't read "sv << config::nvhttp.file_state << ": "sv << e.what(); return; } } @@ -127,14 +127,14 @@ void save_state() { pt::write_json(config::nvhttp.file_state, root); } catch(std::exception &e) { - BOOST_LOG(error) << e.what(); + BOOST_LOG(error) << "Couldn't write "sv << config::nvhttp.file_state << ": "sv << e.what(); return; } } void load_state() { - auto file_state = fs::current_path() / config::nvhttp.file_state; - if(!fs::exists(file_state)) { + if(!fs::exists(config::nvhttp.file_state)) { + BOOST_LOG(info) << "DOENST EXIST"sv; http::unique_id = util::uuid_t::generate().string(); return; } @@ -144,20 +144,18 @@ void load_state() { pt::read_json(config::nvhttp.file_state, root); } catch(std::exception &e) { - BOOST_LOG(warning) << e.what(); + BOOST_LOG(error) << "Couldn't read "sv << config::nvhttp.file_state << ": "sv << e.what(); return; } - auto unique_id_p = root.find("root.uniqueid"s); - if(unique_id_p == root.not_found()) { + auto unique_id_p = root.get_optional("root.uniqueid"); + if(!unique_id_p) { // This file doesn't contain moonlight credentials http::unique_id = util::uuid_t::generate().string(); return; } - else { - http::unique_id = root.get("root.uniqueid"); - } + http::unique_id = std::move(*unique_id_p); auto device_nodes = root.get_child("root.devices");