diff options
| author | Nathan Jaremko | 2018-05-16 22:36:50 -0400 | 
|---|---|---|
| committer | Nathan Jaremko | 2018-05-16 22:36:50 -0400 | 
| commit | e394ea52b04a99ba55719a7a9764bca3ebb591d2 (patch) | |
| tree | c35a6d094d89eeec8adeb4e352d8d1c9cb010f7a /src | |
| parent | 0b9e9f9092b72b24ce1ec1fc058107f296c64838 (diff) | |
| download | podcast-e394ea52b04a99ba55719a7a9764bca3ebb591d2.tar.bz2 | |
Attempt to fix windows rename bug
Diffstat (limited to 'src')
| -rw-r--r-- | src/actions.rs | 4 | ||||
| -rw-r--r-- | src/main.rs | 2 | ||||
| -rw-r--r-- | src/structs.rs | 16 | 
3 files changed, 14 insertions, 8 deletions
| diff --git a/src/actions.rs b/src/actions.rs index 8adea4c..6a8951d 100644 --- a/src/actions.rs +++ b/src/actions.rs @@ -264,7 +264,9 @@ pub fn play_episode(state: &State, p_search: &str, ep_num_string: &str) -> Resul              if path.exists() {                  launch_player(path.to_str().chain_err(|| UNABLE_TO_CONVERT_TO_STR)?)?;              } else { -                launch_player(episode.url().chain_err(|| "unable to retrieve episode url")?)?; +                launch_player(episode +                    .url() +                    .chain_err(|| "unable to retrieve episode url")?)?;              }              return Ok(());          } diff --git a/src/main.rs b/src/main.rs index 35498df..4016199 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,7 @@ use utils::*;  use clap::{App, Arg, SubCommand}; -const VERSION: &str = "0.5.4"; +const VERSION: &str = "0.5.5";  fn main() -> Result<()> {      create_directories().chain_err(|| "unable to create directories")?; diff --git a/src/structs.rs b/src/structs.rs index 03a9932..0caed73 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -67,9 +67,11 @@ impl State {          path.push(".subscriptions");          if path.exists() {              let mut s = String::new(); -            let mut file = File::open(&path).chain_err(|| UNABLE_TO_OPEN_FILE)?; -            file.read_to_string(&mut s) -                .chain_err(|| UNABLE_TO_READ_FILE_TO_STRING)?; +            { +                let mut file = File::open(&path).chain_err(|| UNABLE_TO_OPEN_FILE)?; +                file.read_to_string(&mut s) +                    .chain_err(|| UNABLE_TO_READ_FILE_TO_STRING)?; +            }              let mut state: State = match serde_json::from_str(&s) {                  Ok(val) => val,                  // This will happen if the struct has changed between versions @@ -132,9 +134,11 @@ impl State {          let mut path = get_podcast_dir()?;          path.push(".subscriptions.tmp");          let serialized = serde_json::to_string(self).chain_err(|| "unable to serialize state")?; -        let mut file = File::create(&path).chain_err(|| UNABLE_TO_CREATE_FILE)?; -        file.write_all(serialized.as_bytes()) -            .chain_err(|| UNABLE_TO_WRITE_FILE)?; +        { +            let mut file = File::create(&path).chain_err(|| UNABLE_TO_CREATE_FILE)?; +            file.write_all(serialized.as_bytes()) +                .chain_err(|| UNABLE_TO_WRITE_FILE)?; +        }          fs::rename(&path, get_sub_file()?).chain_err(|| "unable to rename file")?;          Ok(())      } | 
