forked from NG-SD-Plugins/PowerTools
Only commit Deck CPU & GPU frequency settings when no errors occur
This commit is contained in:
parent
2b94298e8c
commit
7acff88b14
6 changed files with 19 additions and 15 deletions
2
backend/Cargo.lock
generated
2
backend/Cargo.lock
generated
|
@ -826,7 +826,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "powertools"
|
name = "powertools"
|
||||||
version = "1.2.0-beta2"
|
version = "1.2.0-beta3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"limits_core",
|
"limits_core",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "powertools"
|
name = "powertools"
|
||||||
version = "1.2.0-beta2"
|
version = "1.2.0-beta3"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
authors = ["NGnius (Graham) <ngniusness@gmail.com>"]
|
||||||
description = "Backend (superuser) functionality for PowerTools"
|
description = "Backend (superuser) functionality for PowerTools"
|
||||||
|
|
|
@ -302,7 +302,7 @@ impl Cpu {
|
||||||
},
|
},
|
||||||
).unwrap_or_else(|e| errors.push(e));
|
).unwrap_or_else(|e| errors.push(e));
|
||||||
}
|
}
|
||||||
// commit changes
|
|
||||||
usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n")
|
usdpl_back::api::files::write_single(CPU_CLOCK_LIMITS_PATH, "c\n")
|
||||||
.unwrap_or_else(|e| {
|
.unwrap_or_else(|e| {
|
||||||
errors.push(SettingError {
|
errors.push(SettingError {
|
||||||
|
@ -310,9 +310,14 @@ impl Cpu {
|
||||||
setting: crate::settings::SettingVariant::Cpu,
|
setting: crate::settings::SettingVariant::Cpu,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// commit changes (if no errors have already occured)
|
||||||
if errors.is_empty() {
|
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 {
|
} else {
|
||||||
Err(errors)
|
Err(errors)
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,15 +139,14 @@ impl Gpu {
|
||||||
});
|
});
|
||||||
self.set_clocks()
|
self.set_clocks()
|
||||||
.unwrap_or_else(|mut e| errors.append(&mut e));
|
.unwrap_or_else(|mut e| errors.append(&mut e));
|
||||||
// commit changes
|
// commit changes (if no errors have already occured)
|
||||||
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));
|
|
||||||
if errors.is_empty() {
|
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 {
|
} else {
|
||||||
Err(errors)
|
Err(errors)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "PowerTools",
|
"name": "PowerTools",
|
||||||
"version": "1.2.0-beta2",
|
"version": "1.2.0-beta3",
|
||||||
"description": "Power tweaks for power users",
|
"description": "Power tweaks for power users",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "shx rm -rf dist && rollup -c",
|
"build": "shx rm -rf dist && rollup -c",
|
||||||
|
|
|
@ -299,7 +299,7 @@ export default definePlugin((serverApi: ServerAPI) => {
|
||||||
periodicHook = null;
|
periodicHook = null;
|
||||||
lifetimeHook!.unregister();
|
lifetimeHook!.unregister();
|
||||||
startHook!.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.");
|
backend.log(backend.LogLevel.Debug, "Unregistered PowerTools callbacks, so long and thanks for all the fish.");
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue