Skip to content

Commit 3521fa7

Browse files
authored
bin: warn if using oauth without credential caching (librespot-org#1362)
1 parent b35dd8e commit 3521fa7

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,8 @@ fn get_setup() -> Setup {
10921092
tmp_dir
10931093
});
10941094

1095+
let enable_oauth = opt_present(ENABLE_OAUTH);
1096+
10951097
let cache = {
10961098
let volume_dir = opt_str(SYSTEM_CACHE)
10971099
.or_else(|| opt_str(CACHE))
@@ -1139,16 +1141,20 @@ fn get_setup() -> Setup {
11391141
);
11401142
}
11411143

1142-
match Cache::new(cred_dir, volume_dir, audio_dir, limit) {
1144+
let cache = match Cache::new(cred_dir.clone(), volume_dir, audio_dir, limit) {
11431145
Ok(cache) => Some(cache),
11441146
Err(e) => {
11451147
warn!("Cannot create cache: {}", e);
11461148
None
11471149
}
1150+
};
1151+
1152+
if enable_oauth && (cache.is_none() || cred_dir.is_none()) {
1153+
warn!("Credential caching is unavailable, but advisable when using OAuth login.");
11481154
}
1149-
};
11501155

1151-
let enable_oauth = opt_present(ENABLE_OAUTH);
1156+
cache
1157+
};
11521158

11531159
let credentials = {
11541160
let cached_creds = cache.as_ref().and_then(Cache::credentials);

0 commit comments

Comments
 (0)