static enum command_state filescanner_fullrescan(void *arg, int *retval) { DPRINTF(E_LOG, L_SCAN, "Full rescan triggered\n"); player_playback_stop(); player_queue_clear(); inofd_event_unset(); // Clears all inotify watches db_purge_all(); // Clears files, playlists, playlistitems, inotify and groups inofd_event_set(); bulk_scan(F_SCAN_BULK); *retval = 0; return COMMAND_END; }
static enum command_state fullrescan(void *arg, int *ret) { time_t starttime; time_t endtime; int i; DPRINTF(E_LOG, L_LIB, "Library full-rescan triggered\n"); listener_notify(LISTENER_UPDATE); starttime = time(NULL); player_playback_stop(); db_queue_clear(0); db_purge_all(); // Clears files, playlists, playlistitems, inotify and groups for (i = 0; sources[i]; i++) { if (!sources[i]->disabled && sources[i]->fullrescan) { DPRINTF(E_INFO, L_LIB, "Full-rescan library source '%s'\n", sources[i]->name); sources[i]->fullrescan(); } else { DPRINTF(E_INFO, L_LIB, "Library source '%s' is disabled\n", sources[i]->name); } } endtime = time(NULL); DPRINTF(E_LOG, L_LIB, "Library full-rescan completed in %.f sec (%d changes)\n", difftime(endtime, starttime), deferred_update_notifications); scanning = false; if (handle_deferred_update_notifications()) listener_notify(LISTENER_UPDATE | LISTENER_DATABASE); else listener_notify(LISTENER_UPDATE); *ret = 0; return COMMAND_END; }
/* Thread: scan */ static void process_file(char *file, time_t mtime, off_t size, int type, int flags) { switch (file_type_get(file)) { case FILE_REGULAR: filescanner_process_media(file, mtime, size, type, NULL); counter++; /* When in bulk mode, split transaction in pieces of 200 */ if ((flags & F_SCAN_BULK) && (counter % 200 == 0)) { DPRINTF(E_LOG, L_SCAN, "Scanned %d files...\n", counter); db_transaction_end(); db_transaction_begin(); } break; case FILE_PLAYLIST: case FILE_ITUNES: if (flags & F_SCAN_BULK) defer_playlist(file, mtime); else process_playlist(file, mtime); break; case FILE_CTRL_REMOTE: remote_pairing_read_pin(file); break; #ifdef LASTFM case FILE_CTRL_LASTFM: lastfm_login(file); break; #endif #ifdef HAVE_SPOTIFY_H case FILE_CTRL_SPOTIFY: spotify_login(file); break; #endif case FILE_CTRL_INITSCAN: if (flags & F_SCAN_BULK) break; DPRINTF(E_LOG, L_SCAN, "Startup rescan triggered, found init-rescan file: %s\n", file); inofd_event_unset(); // Clears all inotify watches db_watch_clear(); inofd_event_set(); bulk_scan(F_SCAN_BULK | F_SCAN_RESCAN); break; case FILE_CTRL_FULLSCAN: if (flags & F_SCAN_BULK) break; DPRINTF(E_LOG, L_SCAN, "Full rescan triggered, found full-rescan file: %s\n", file); player_playback_stop(); player_queue_clear(); inofd_event_unset(); // Clears all inotify watches db_purge_all(); // Clears files, playlists, playlistitems, inotify and groups inofd_event_set(); bulk_scan(F_SCAN_BULK); break; default: DPRINTF(E_WARN, L_SCAN, "Ignoring file: %s\n", file); } }