mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-27 06:33:21 -05:00
Run event loop for each directory and each playlist when scanning in bulk mode
This commit is contained in:
parent
4e38d168e1
commit
c8cc6bd603
@ -367,7 +367,7 @@ defer_playlist(char *path)
|
|||||||
DPRINTF(E_INFO, L_SCAN, "Deferred playlist %s\n", path);
|
DPRINTF(E_INFO, L_SCAN, "Deferred playlist %s\n", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Thread: scan */
|
/* Thread: scan (bulk only) */
|
||||||
static void
|
static void
|
||||||
process_deferred_playlists(void)
|
process_deferred_playlists(void)
|
||||||
{
|
{
|
||||||
@ -381,6 +381,12 @@ process_deferred_playlists(void)
|
|||||||
|
|
||||||
free(pl->path);
|
free(pl->path);
|
||||||
free(pl);
|
free(pl);
|
||||||
|
|
||||||
|
/* Run the event loop */
|
||||||
|
event_base_loop(evbase_scan, EVLOOP_ONCE | EVLOOP_NONBLOCK);
|
||||||
|
|
||||||
|
if (scan_exit)
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,6 +437,7 @@ check_compilation(cfg_t *lib, char *path)
|
|||||||
static void
|
static void
|
||||||
process_directory(cfg_t *lib, char *path, int bulk)
|
process_directory(cfg_t *lib, char *path, int bulk)
|
||||||
{
|
{
|
||||||
|
struct stacked_dir *bulkstack;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent buf;
|
struct dirent buf;
|
||||||
struct dirent *de;
|
struct dirent *de;
|
||||||
@ -443,6 +450,24 @@ process_directory(cfg_t *lib, char *path, int bulk)
|
|||||||
int compilation;
|
int compilation;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (bulk)
|
||||||
|
{
|
||||||
|
/* Save our directory stack so it won't get handled inside
|
||||||
|
* the event loop - not its business, we're in bulk mode here.
|
||||||
|
*/
|
||||||
|
bulkstack = dirstack;
|
||||||
|
dirstack = NULL;
|
||||||
|
|
||||||
|
/* Run the event loop */
|
||||||
|
event_base_loop(evbase_scan, EVLOOP_ONCE | EVLOOP_NONBLOCK);
|
||||||
|
|
||||||
|
/* Restore our directory stack */
|
||||||
|
dirstack = bulkstack;
|
||||||
|
|
||||||
|
if (scan_exit)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINTF(E_DBG, L_SCAN, "Processing directory %s (bulk = %d)\n", path, bulk);
|
DPRINTF(E_DBG, L_SCAN, "Processing directory %s (bulk = %d)\n", path, bulk);
|
||||||
|
|
||||||
dirp = opendir(path);
|
dirp = opendir(path);
|
||||||
@ -569,34 +594,21 @@ process_directory(cfg_t *lib, char *path, int bulk)
|
|||||||
static void
|
static void
|
||||||
process_directories(cfg_t *lib, char *root, int bulk)
|
process_directories(cfg_t *lib, char *root, int bulk)
|
||||||
{
|
{
|
||||||
struct stacked_dir *bulkstack;
|
|
||||||
char *path;
|
char *path;
|
||||||
|
|
||||||
process_directory(lib, root, bulk);
|
process_directory(lib, root, bulk);
|
||||||
|
|
||||||
|
if (bulk && scan_exit)
|
||||||
|
return;
|
||||||
|
|
||||||
while ((path = pop_dir()))
|
while ((path = pop_dir()))
|
||||||
{
|
{
|
||||||
process_directory(lib, path, bulk);
|
process_directory(lib, path, bulk);
|
||||||
|
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
if (bulk)
|
if (bulk && scan_exit)
|
||||||
{
|
return;
|
||||||
/* Save our directory stack so it won't get handled inside
|
|
||||||
* the event loop - not its business, we're in bulk mode here.
|
|
||||||
*/
|
|
||||||
bulkstack = dirstack;
|
|
||||||
dirstack = NULL;
|
|
||||||
|
|
||||||
/* Run the event loop */
|
|
||||||
event_base_loop(evbase_scan, EVLOOP_ONCE | EVLOOP_NONBLOCK);
|
|
||||||
|
|
||||||
/* Restore our directory stack */
|
|
||||||
dirstack = bulkstack;
|
|
||||||
|
|
||||||
if (scan_exit)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -640,6 +652,9 @@ bulk_scan(void)
|
|||||||
if (playlists)
|
if (playlists)
|
||||||
process_deferred_playlists();
|
process_deferred_playlists();
|
||||||
|
|
||||||
|
if (scan_exit)
|
||||||
|
return;
|
||||||
|
|
||||||
if (dirstack)
|
if (dirstack)
|
||||||
DPRINTF(E_LOG, L_SCAN, "WARNING: unhandled leftover directories\n");
|
DPRINTF(E_LOG, L_SCAN, "WARNING: unhandled leftover directories\n");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user