bin: warn if using oauth without credential caching (#1362)

This commit is contained in:
Nick Steel 2024-10-06 21:08:53 +01:00 committed by GitHub
parent 54ea9266df
commit 469442f681
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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);