Run event loop for each directory and each playlist when scanning in bulk mode

This commit is contained in:
Julien BLACHE 2009-06-09 12:12:00 +02:00
parent 4e38d168e1
commit c8cc6bd603

View File

@ -367,7 +367,7 @@ defer_playlist(char *path)
DPRINTF(E_INFO, L_SCAN, "Deferred playlist %s\n", path);
}
/* Thread: scan */
/* Thread: scan (bulk only) */
static void
process_deferred_playlists(void)
{
@ -381,6 +381,12 @@ process_deferred_playlists(void)
free(pl->path);
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
process_directory(cfg_t *lib, char *path, int bulk)
{
struct stacked_dir *bulkstack;
DIR *dirp;
struct dirent buf;
struct dirent *de;
@ -443,6 +450,24 @@ process_directory(cfg_t *lib, char *path, int bulk)
int compilation;
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);
dirp = opendir(path);
@ -569,34 +594,21 @@ process_directory(cfg_t *lib, char *path, int bulk)
static void
process_directories(cfg_t *lib, char *root, int bulk)
{
struct stacked_dir *bulkstack;
char *path;
process_directory(lib, root, bulk);
if (bulk && scan_exit)
return;
while ((path = pop_dir()))
{
process_directory(lib, path, bulk);
free(path);
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;
}
if (bulk && scan_exit)
return;
}
}
@ -640,6 +652,9 @@ bulk_scan(void)
if (playlists)
process_deferred_playlists();
if (scan_exit)
return;
if (dirstack)
DPRINTF(E_LOG, L_SCAN, "WARNING: unhandled leftover directories\n");