Skip to content

Commit

Permalink
fix(CLI): adjust JsonTokenStorage to yup-oauth
Browse files Browse the repository at this point in the history
Signature of `set()` changed to return a `Result<(), _>` instead of
an `Option<_>`.

Related to dermesser/yup-oauth2#5
[skip ci]
  • Loading branch information
Byron committed Apr 30, 2015
1 parent 2f20021 commit 94c821e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/rust/cli/cmn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,27 +212,27 @@ impl TokenStorage for JsonTokenStorage {
type Error = json::Error;

// NOTE: logging might be interesting, currently we swallow all errors
fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Option<json::Error> {
fn set(&mut self, scope_hash: u64, _: &Vec<&str>, token: Option<Token>) -> Result<(), json::Error> {
match token {
None => {
match fs::remove_file(self.path(scope_hash)) {
Err(err) =>
match err.kind() {
io::ErrorKind::NotFound => None,
_ => Some(json::Error::IoError(err))
io::ErrorKind::NotFound => Ok(()),
_ => Err(json::Error::IoError(err))
},
Ok(_) => None
Ok(_) => Ok(()),
}
}
Some(token) => {
match fs::OpenOptions::new().create(true).write(true).open(&self.path(scope_hash)) {
Ok(mut f) => {
match json::to_writer_pretty(&mut f, &token) {
Ok(_) => None,
Err(io_err) => Some(json::Error::IoError(io_err)),
Ok(_) => Ok(()),
Err(io_err) => Err(json::Error::IoError(io_err)),
}
},
Err(io_err) => Some(json::Error::IoError(io_err))
Err(io_err) => Err(json::Error::IoError(io_err))
}
}
}
Expand Down

0 comments on commit 94c821e

Please sign in to comment.