mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
do not overwrite unchanged cached Credentials (#1168)
This commit is contained in:
parent
c491f90e09
commit
ebf600d96e
2 changed files with 8 additions and 2 deletions
|
@ -27,7 +27,7 @@ impl From<AuthenticationError> for Error {
|
|||
}
|
||||
|
||||
/// The credentials are used to log into the Spotify API.
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
|
||||
pub struct Credentials {
|
||||
pub username: String,
|
||||
|
||||
|
|
|
@ -176,7 +176,13 @@ impl Session {
|
|||
self.set_username(&reusable_credentials.username);
|
||||
if let Some(cache) = self.cache() {
|
||||
if store_credentials {
|
||||
cache.save_credentials(&reusable_credentials);
|
||||
let cred_changed = cache
|
||||
.credentials()
|
||||
.map(|c| c != reusable_credentials)
|
||||
.unwrap_or(true);
|
||||
if cred_changed {
|
||||
cache.save_credentials(&reusable_credentials);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue