Skip to content

Commit

Permalink
prettier warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
vsbuffalo committed Aug 25, 2023
1 parent 0d72773 commit 8112335
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/lib/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ impl DataCollection {
e.insert(data_file);
Ok(())
} else {
Err(anyhow!("File '{}' is already registered in the data manifest. \
Err(anyhow!("File '{}' is already registered in the data manifest.\n\
If you wish to update the MD5 or metadata, use: sdf update FILE",
&data_file.path))
}
Expand Down
15 changes: 11 additions & 4 deletions src/lib/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,18 +207,24 @@ impl Remote {
}

pub fn authenticate_remote(remote: &mut Remote) -> Result<()> {
// Get they keys off disk
// Get the keys off disk
let auth_keys = AuthKeys::new();
#[allow(clippy::single_match)]
let error_message = |service_name: &str, token_name: &str| {
format!("Expected {} access token not found.\n\n\
If you used 'sdf link', it should have saved this token in ~/.scidataflow_authkeys.yml.\n\
You will need to re-add this key manually, by adding a line to this file like:\n\
{}: <TOKEN>", service_name, token_name)
};

match remote {
Remote::FigShareAPI(ref mut fgsh_api) => {
let token = auth_keys.keys.get("figshare").cloned()
.ok_or_else(|| anyhow::anyhow!("Expected figshare key not found"))?;
.ok_or_else(|| anyhow::anyhow!(error_message("FigShare", "figshare")))?;
fgsh_api.set_token(token);
},
Remote::ZenodoAPI(ref mut znd_api) => {
let token = auth_keys.keys.get("zenodo").cloned()
.ok_or_else(|| anyhow::anyhow!("Expected figshare key not found"))?;
.ok_or_else(|| anyhow::anyhow!(error_message("Zenodo", "zenodo")))?;
znd_api.set_token(token);
},
// handle other Remote variants as necessary
Expand All @@ -227,6 +233,7 @@ pub fn authenticate_remote(remote: &mut Remote) -> Result<()> {
Ok(())
}


// Common enum for issue_request() methods of APIs
#[derive(Debug)]
pub enum RequestData<T: serde::Serialize> {
Expand Down

0 comments on commit 8112335

Please sign in to comment.