Skip to content

Commit

Permalink
bin: warn if using oauth without credential caching (#1362)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingosticks authored Oct 6, 2024
1 parent 54ea926 commit 469442f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,8 @@ fn get_setup() -> Setup {
tmp_dir
});

let enable_oauth = opt_present(ENABLE_OAUTH);

let cache = {
let volume_dir = opt_str(SYSTEM_CACHE)
.or_else(|| opt_str(CACHE))
Expand Down Expand Up @@ -1139,16 +1141,20 @@ fn get_setup() -> Setup {
);
}

match Cache::new(cred_dir, volume_dir, audio_dir, limit) {
let cache = match Cache::new(cred_dir.clone(), volume_dir, audio_dir, limit) {
Ok(cache) => Some(cache),
Err(e) => {
warn!("Cannot create cache: {}", e);
None
}
};

if enable_oauth && (cache.is_none() || cred_dir.is_none()) {
warn!("Credential caching is unavailable, but advisable when using OAuth login.");
}
};

let enable_oauth = opt_present(ENABLE_OAUTH);
cache
};

let credentials = {
let cached_creds = cache.as_ref().and_then(Cache::credentials);
Expand Down

0 comments on commit 469442f

Please sign in to comment.