Skip to content

Commit

Permalink
Fix for Failed to persist temporary file (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-pro authored Apr 9, 2024
1 parent bdb7a87 commit 6a81ca8
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "solar-screen-brightness"
version = "2.3.0"
version = "2.3.1"
authors = ["Jacob Halsey <[email protected]>"]
edition = "2021"
build = "build.rs"
Expand Down
8 changes: 3 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ pub struct BrightnessValues {

impl SsbConfig {
pub fn load(path_override: Option<PathBuf>) -> anyhow::Result<Option<Self>> {
let path = match path_override {
None => get_default_config_path(),
Some(p) => p,
};
let path = path_override.unwrap_or_else(get_default_config_path);
if !path.exists() {
return Ok(None);
}
Expand All @@ -100,7 +97,8 @@ impl SsbConfig {
pub fn save(&self) -> anyhow::Result<()> {
let path = get_default_config_path();
let serialised = serde_json::to_string_pretty(&self).unwrap();
let mut temp_file = NamedTempFile::new()?;
let parent = path.parent().expect("config path must have parent");
let mut temp_file = NamedTempFile::new_in(parent)?;
temp_file.write_all(serialised.as_bytes())?;
temp_file.flush()?;
temp_file.persist(&path)?;
Expand Down
1 change: 1 addition & 0 deletions src/unique/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use windows::Win32::UI::WindowsAndMessaging::{SendMessageW, HWND_BROADCAST};

const APP_ID: &str = "solar-screen-brightness";

#[allow(dead_code)]
pub struct SsbUniqueInstance(UniqueInstance);

impl SsbUniqueInstance {
Expand Down

0 comments on commit 6a81ca8

Please sign in to comment.