mirror of
https://github.com/owntone/owntone-server.git
synced 2024-12-27 23:55:57 -05:00
[spotify] Prevent duplicate scan on startup
The logged_in callback is called during relogin in the initscan. Additionally initscan explicitly starts the scan leading to a duplicate scan run. To prevent this from happening removed the scan call in the logged_in callback and split the spotify_login_user function into a private function (without scan) and a public function (with scan).
This commit is contained in:
parent
83d8a55701
commit
210e6228bc
@ -1138,9 +1138,6 @@ logged_in(sp_session *sess, sp_error error)
|
||||
CHECK_ERR(L_SPOTIFY, pthread_mutex_unlock(&login_lck));
|
||||
|
||||
listener_notify(LISTENER_SPOTIFY);
|
||||
|
||||
// Trigger scan after successful login to libspotify
|
||||
library_exec_async(webapi_rescan, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1571,10 +1568,11 @@ spotify_status_info_get(struct spotify_status_info *info)
|
||||
}
|
||||
|
||||
/* Thread: library, httpd */
|
||||
int
|
||||
spotify_login_user(const char *user, const char *password, char **errmsg)
|
||||
static int
|
||||
login_user(const char *user, const char *password, char **errmsg)
|
||||
{
|
||||
sp_error err;
|
||||
int ret;
|
||||
|
||||
if (!g_sess)
|
||||
{
|
||||
@ -1643,7 +1641,30 @@ spotify_login_user(const char *user, const char *password, char **errmsg)
|
||||
CHECK_ERR(L_SPOTIFY, pthread_cond_wait(&login_cond, &login_lck));
|
||||
CHECK_ERR(L_SPOTIFY, pthread_mutex_unlock(&login_lck));
|
||||
|
||||
return 0;
|
||||
CHECK_ERR(L_SPOTIFY, pthread_mutex_lock(&status_lck));
|
||||
ret = spotify_status_info.libspotify_logged_in ? 0 : -1;
|
||||
CHECK_ERR(L_SPOTIFY, pthread_mutex_unlock(&status_lck));
|
||||
|
||||
if (ret < 0 && errmsg)
|
||||
*errmsg = safe_asprintf("Login failed");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Thread: httpd, library */
|
||||
int
|
||||
spotify_login_user(const char *user, const char *password, char **errmsg)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = login_user(user, password, errmsg);
|
||||
if (ret == 0)
|
||||
{
|
||||
// Trigger scan after successful login to libspotify
|
||||
library_exec_async(webapi_rescan, NULL);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Thread: library */
|
||||
@ -2004,7 +2025,7 @@ initscan()
|
||||
* Login to spotify needs to be done before scanning tracks from the web api.
|
||||
* (Scanned tracks need to be registered with libspotify for playback)
|
||||
*/
|
||||
spotify_login_user(NULL, NULL, NULL);
|
||||
login_user(NULL, NULL, NULL);
|
||||
|
||||
/*
|
||||
* Scan saved tracks from the web api
|
||||
|
Loading…
Reference in New Issue
Block a user