mirror of
https://github.com/librespot-org/librespot.git
synced 2024-11-08 16:45:43 +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,9 +176,15 @@ impl Session {
|
|||
self.set_username(&reusable_credentials.username);
|
||||
if let Some(cache) = self.cache() {
|
||||
if store_credentials {
|
||||
let cred_changed = cache
|
||||
.credentials()
|
||||
.map(|c| c != reusable_credentials)
|
||||
.unwrap_or(true);
|
||||
if cred_changed {
|
||||
cache.save_credentials(&reusable_credentials);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let (tx_connection, rx_connection) = mpsc::unbounded_channel();
|
||||
self.0
|
||||
|
|
Loading…
Reference in a new issue