From 7acff88b145e6d6cbbc6e327267aea7c0b5e3e6e Mon Sep 17 00:00:00 2001 From: "NGnius (Graham)" Date: Sun, 26 Feb 2023 13:04:09 -0500 Subject: [PATCH] Only commit Deck CPU & GPU frequency settings when no errors occur --- backend/Cargo.lock | 2 +- backend/Cargo.toml | 2 +- backend/src/settings/steam_deck/cpu.rs | 11 ++++++++--- backend/src/settings/steam_deck/gpu.rs | 15 +++++++-------- package.json | 2 +- src/index.tsx | 2 +- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/backend/Cargo.lock b/backend/Cargo.lock index ab9ac0a..83a7797 100644 --- a/backend/Cargo.lock +++ b/backend/Cargo.lock @@ -826,7 +826,7 @@ dependencies = [ [[package]] name = "powertools" -version = "1.2.0-beta2" +version = "1.2.0-beta3" dependencies = [ "async-trait", "limits_core", diff --git a/backend/Cargo.toml b/backend/Cargo.toml index d202c32..af497d3 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "powertools" -version = "1.2.0-beta2" +version = "1.2.0-beta3" edition = "2021" authors = ["NGnius (Graham) "] description = "Backend (superuser) functionality for PowerTools" diff --git a/backend/src/settings/steam_deck/cpu.rs b/backend/src/settings/steam_deck/cpu.rs index 97adea7..28ab7a7 100644 --- a/backend/src/settings/steam_deck/cpu.rs +++ b/backend/src/settings/steam_deck/cpu.rs @@ -302,7 +302,7 @@ impl Cpu { }, ).unwrap_or_else(|e| errors.push(e)); } - // commit changes + usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n") .unwrap_or_else(|e| { errors.push(SettingError { @@ -310,9 +310,14 @@ impl Cpu { setting: crate::settings::SettingVariant::Cpu, }); }); - + // commit changes (if no errors have already occured) if errors.is_empty() { - Ok(()) + usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n").map_err(|e| { + vec![SettingError { + msg: format!("Failed to write `c` to `{}`: {}", CPU_CLOCK_LIMITS_PATH, e), + setting: crate::settings::SettingVariant::Cpu, + }] + }) } else { Err(errors) } diff --git a/backend/src/settings/steam_deck/gpu.rs b/backend/src/settings/steam_deck/gpu.rs index fef4498..b89be00 100644 --- a/backend/src/settings/steam_deck/gpu.rs +++ b/backend/src/settings/steam_deck/gpu.rs @@ -139,15 +139,14 @@ impl Gpu { }); self.set_clocks() .unwrap_or_else(|mut e| errors.append(&mut e)); - // commit changes - usdpl_back::api::files::write_single(GPU_CLOCK_LIMITS_PATH, "c\n").map_err(|e| { - SettingError { - msg: format!("Failed to write `c` to `{}`: {}", GPU_CLOCK_LIMITS_PATH, e), - setting: crate::settings::SettingVariant::Gpu, - } - }).unwrap_or_else(|e| errors.push(e)); + // commit changes (if no errors have already occured) if errors.is_empty() { - Ok(()) + usdpl_back::api::files::write_single(GPU_CLOCK_LIMITS_PATH, "c\n").map_err(|e| { + vec![SettingError { + msg: format!("Failed to write `c` to `{}`: {}", GPU_CLOCK_LIMITS_PATH, e), + setting: crate::settings::SettingVariant::Gpu, + }] + }) } else { Err(errors) } diff --git a/package.json b/package.json index 8a73eba..bb2ea60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "PowerTools", - "version": "1.2.0-beta2", + "version": "1.2.0-beta3", "description": "Power tweaks for power users", "scripts": { "build": "shx rm -rf dist && rollup -c", diff --git a/src/index.tsx b/src/index.tsx index 03e8d4d..25bdd22 100755 --- a/src/index.tsx +++ b/src/index.tsx @@ -299,7 +299,7 @@ export default definePlugin((serverApi: ServerAPI) => { periodicHook = null; lifetimeHook!.unregister(); startHook!.unregister(); - serverApi.routerHook.removeRoute("/decky-plugin-test"); + //serverApi.routerHook.removeRoute("/decky-plugin-test"); backend.log(backend.LogLevel.Debug, "Unregistered PowerTools callbacks, so long and thanks for all the fish."); }, };