From 7314d0de0d85663d3417a3251a858d876930219b Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Tue, 28 Jan 2014 22:40:07 +0100 Subject: [PATCH] Add config option to disable initial file scan --- forked-daapd.conf | 16 +++++++++++++++- src/conffile.c | 3 ++- src/filescanner.c | 32 ++++++++++++++++++++++---------- 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/forked-daapd.conf b/forked-daapd.conf index 2bfe8b6a..65ce4bb2 100644 --- a/forked-daapd.conf +++ b/forked-daapd.conf @@ -31,23 +31,27 @@ library { # names. If there is a match all items in the directory are marked as # podcasts. Eg. if you index /srv/music, and your podcasts are in # /srv/music/Podcasts, you can set this to "/Podcasts". + # (changing this setting only takes effect after rescan, see the README) podcasts = { "/Podcasts" } # Directories containing audiobooks # For each directory that is indexed the path is matched against these # names. If there is a match all items in the directory are marked as # audiobooks. + # (changing this setting only takes effect after rescan, see the README) audiobooks = { "/Audiobooks" } # Directories containing compilations (eg soundtracks) # For each directory that is indexed the path is matched against these # names. If there is a match all items in the directory are marked as # compilations. + # (changing this setting only takes effect after rescan, see the README) compilations = { "/Compilations" } # Compilations usually have many artists, and if you don't want every # artist to be listed when artist browsing in Remote, you can set # a single name which will be used for all music in the compilation dir + # (changing this setting only takes effect after rescan, see the README) compilation_artist = "Various artists" # There are 5 default playlists: "Library", "Music", "Movies", "TV Shows" @@ -69,8 +73,18 @@ library { # scan time. By default .db and .ini are ignored. # filetypes_ignore = { ".db", ".ini" } + # Disable startup file scanning + # When forked-daapd starts it will do an initial file scan of your + # library (and then watch it for changes). If you are sure your library + # never changes while forked-daapd is not running, you can disable the + # initial file scan and save some system ressources. Disabling this scan + # may lead to forked-daapd's database coming out of sync with the + # library. If that happens read the instructions in the README on how + # to trigger a full rescan. +# filescan_disable = false + # Should iTunes metadata override ours? -# itunes_overrides = true +# itunes_overrides = false # Formats: mp4a, mp4v, mpeg, alac, flac, mpc, ogg, wma, wmal, wmav, aif, wav # Formats that should never be transcoded diff --git a/src/conffile.c b/src/conffile.c index e4c33083..5f2045d5 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -49,7 +49,7 @@ static cfg_opt_t sec_general[] = CFG_STR("logfile", STATEDIR "/log/" PACKAGE ".log", CFGF_NONE), CFG_STR("db_path", STATEDIR "/cache/" PACKAGE "/songs3.db", CFGF_NONE), CFG_INT_CB("loglevel", E_LOG, CFGF_NONE, &cb_loglevel), - CFG_BOOL("ipv6", cfg_true, CFGF_NONE), + CFG_BOOL("ipv6", cfg_false, CFGF_NONE), CFG_END() }; @@ -72,6 +72,7 @@ static cfg_opt_t sec_library[] = CFG_STR("name_audiobooks", "Audiobooks", CFGF_NONE), CFG_STR_LIST("artwork_basenames", "{artwork,cover,Folder}", CFGF_NONE), CFG_STR_LIST("filetypes_ignore", "{.db,.ini}", CFGF_NONE), + CFG_BOOL("filescan_disable", cfg_false, CFGF_NONE), CFG_BOOL("itunes_overrides", cfg_false, CFGF_NONE), CFG_STR_LIST("no_transcode", NULL, CFGF_NONE), CFG_STR_LIST("force_transcode", NULL, CFGF_NONE), diff --git a/src/filescanner.c b/src/filescanner.c index 84bba443..d0bf1b2f 100644 --- a/src/filescanner.c +++ b/src/filescanner.c @@ -63,6 +63,7 @@ #define F_SCAN_BULK (1 << 0) #define F_SCAN_RESCAN (1 << 1) +#define F_SCAN_FAST (1 << 2) struct deferred_pl { char *path; @@ -92,7 +93,7 @@ static struct stacked_dir *dirstack; /* Forward */ static void -bulk_scan(void); +bulk_scan(int flags); static int push_dir(struct stacked_dir **s, char *path) @@ -601,7 +602,7 @@ process_file(char *file, time_t mtime, off_t size, int type, int flags) { DPRINTF(E_LOG, L_SCAN, "Forcing full rescan, found force-rescan file: %s\n", file); db_purge_all(); - bulk_scan(); + bulk_scan(F_SCAN_BULK); return; } @@ -748,7 +749,10 @@ process_directory(char *path, int flags) } if (S_ISREG(sb.st_mode)) - process_file(entry, sb.st_mtime, sb.st_size, type, flags); + { + if (!(flags & F_SCAN_FAST)) + process_file(entry, sb.st_mtime, sb.st_size, type, flags); + } else if (S_ISDIR(sb.st_mode)) push_dir(&dirstack, entry); else @@ -832,7 +836,7 @@ process_directories(char *root, int flags) /* Thread: scan */ static void -bulk_scan(void) +bulk_scan(int flags) { cfg_t *lib; int ndirs; @@ -868,7 +872,7 @@ bulk_scan(void) continue; } - process_directories(deref, F_SCAN_BULK); + process_directories(deref, flags); free(deref); @@ -876,7 +880,7 @@ bulk_scan(void) return; } - if (playlists) + if (!(flags & F_SCAN_FAST) && playlists) process_deferred_playlists(); if (scan_exit) @@ -885,10 +889,15 @@ bulk_scan(void) if (dirstack) DPRINTF(E_LOG, L_SCAN, "WARNING: unhandled leftover directories\n"); - DPRINTF(E_DBG, L_SCAN, "Purging old database content\n"); - db_purge_cruft(start); + if (flags & F_SCAN_FAST) + DPRINTF(E_LOG, L_SCAN, "Bulk library scan complete (with file scan disabled)\n"); + else + { + DPRINTF(E_DBG, L_SCAN, "Purging old database content\n"); + db_purge_cruft(start); - DPRINTF(E_LOG, L_SCAN, "Bulk library scan complete\n"); + DPRINTF(E_LOG, L_SCAN, "Bulk library scan complete\n"); + } } @@ -929,7 +938,10 @@ filescanner(void *arg) db_files_update_songartistid(); db_files_update_songalbumid(); - bulk_scan(); + if (cfg_getbool(cfg_getsec(cfg, "library"), "filescan_disable")) + bulk_scan(F_SCAN_BULK | F_SCAN_FAST); + else + bulk_scan(F_SCAN_BULK); db_hook_post_scan();