mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
bin: warn if using oauth without credential caching (#1362)
This commit is contained in:
parent
54ea9266df
commit
469442f681
1 changed files with 10 additions and 4 deletions
14
src/main.rs
14
src/main.rs
|
@ -1092,6 +1092,8 @@ fn get_setup() -> Setup {
|
||||||
tmp_dir
|
tmp_dir
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let enable_oauth = opt_present(ENABLE_OAUTH);
|
||||||
|
|
||||||
let cache = {
|
let cache = {
|
||||||
let volume_dir = opt_str(SYSTEM_CACHE)
|
let volume_dir = opt_str(SYSTEM_CACHE)
|
||||||
.or_else(|| opt_str(CACHE))
|
.or_else(|| opt_str(CACHE))
|
||||||
|
@ -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),
|
Ok(cache) => Some(cache),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!("Cannot create cache: {}", e);
|
warn!("Cannot create cache: {}", e);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let enable_oauth = opt_present(ENABLE_OAUTH);
|
if enable_oauth && (cache.is_none() || cred_dir.is_none()) {
|
||||||
|
warn!("Credential caching is unavailable, but advisable when using OAuth login.");
|
||||||
|
}
|
||||||
|
|
||||||
|
cache
|
||||||
|
};
|
||||||
|
|
||||||
let credentials = {
|
let credentials = {
|
||||||
let cached_creds = cache.as_ref().and_then(Cache::credentials);
|
let cached_creds = cache.as_ref().and_then(Cache::credentials);
|
||||||
|
|
Loading…
Reference in a new issue