Skip to content

Commit

Permalink
Don't use Result for get_cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
jackTabsCode committed Jun 7, 2024
1 parent fe20f54 commit efe72ad
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions src/commands/sync/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,16 @@ fn get_api_key(arg_key: Option<String>) -> anyhow::Result<String> {
}
}

fn get_cookie(arg_cookie: Option<String>) -> anyhow::Result<Option<String>> {
fn get_cookie(arg_cookie: Option<String>) -> Option<String> {
let env_cookie = env::var("ASPHALT_COOKIE").ok();
let cookie_str = arg_cookie.or(env_cookie).or(rbx_cookie::get_value());

if let Some(cookie) = cookie_str {
Ok(Some(
Cookie::build(".ROBLOSECURITY", cookie)
.domain(".roblox.com")
.finish()
.to_string(),
))
} else {
Ok(None)
}
cookie_str.map(|cookie| {
Cookie::build(".ROBLOSECURITY", cookie)
.domain(".roblox.com")
.finish()
.to_string()
})
}

pub struct SyncState {
Expand Down Expand Up @@ -71,7 +67,7 @@ impl SyncState {
existing_lockfile: LockFile,
) -> anyhow::Result<Self> {
let api_key = get_api_key(args.api_key)?;
let cookie = get_cookie(args.cookie)?;
let cookie = get_cookie(args.cookie);

let creator: AssetCreator = match config.creator.creator_type {
CreatorType::User => AssetCreator::User(AssetUserCreator {
Expand Down

0 comments on commit efe72ad

Please sign in to comment.