Add config option to disable initial file scan

This commit is contained in:
ejurgensen 2014-01-28 22:40:07 +01:00
parent 21fe5ac3a6
commit 7314d0de0d
3 changed files with 39 additions and 12 deletions

View File

@ -31,23 +31,27 @@ library {
# names. If there is a match all items in the directory are marked as # 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 # podcasts. Eg. if you index /srv/music, and your podcasts are in
# /srv/music/Podcasts, you can set this to "/Podcasts". # /srv/music/Podcasts, you can set this to "/Podcasts".
# (changing this setting only takes effect after rescan, see the README)
podcasts = { "/Podcasts" } podcasts = { "/Podcasts" }
# Directories containing audiobooks # Directories containing audiobooks
# For each directory that is indexed the path is matched against these # 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 # names. If there is a match all items in the directory are marked as
# audiobooks. # audiobooks.
# (changing this setting only takes effect after rescan, see the README)
audiobooks = { "/Audiobooks" } audiobooks = { "/Audiobooks" }
# Directories containing compilations (eg soundtracks) # Directories containing compilations (eg soundtracks)
# For each directory that is indexed the path is matched against these # 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 # names. If there is a match all items in the directory are marked as
# compilations. # compilations.
# (changing this setting only takes effect after rescan, see the README)
compilations = { "/Compilations" } compilations = { "/Compilations" }
# Compilations usually have many artists, and if you don't want every # Compilations usually have many artists, and if you don't want every
# artist to be listed when artist browsing in Remote, you can set # 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 # 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" compilation_artist = "Various artists"
# There are 5 default playlists: "Library", "Music", "Movies", "TV Shows" # There are 5 default playlists: "Library", "Music", "Movies", "TV Shows"
@ -69,8 +73,18 @@ library {
# scan time. By default .db and .ini are ignored. # scan time. By default .db and .ini are ignored.
# filetypes_ignore = { ".db", ".ini" } # 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? # 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: mp4a, mp4v, mpeg, alac, flac, mpc, ogg, wma, wmal, wmav, aif, wav
# Formats that should never be transcoded # Formats that should never be transcoded

View File

@ -49,7 +49,7 @@ static cfg_opt_t sec_general[] =
CFG_STR("logfile", STATEDIR "/log/" PACKAGE ".log", CFGF_NONE), CFG_STR("logfile", STATEDIR "/log/" PACKAGE ".log", CFGF_NONE),
CFG_STR("db_path", STATEDIR "/cache/" PACKAGE "/songs3.db", CFGF_NONE), CFG_STR("db_path", STATEDIR "/cache/" PACKAGE "/songs3.db", CFGF_NONE),
CFG_INT_CB("loglevel", E_LOG, CFGF_NONE, &cb_loglevel), 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() CFG_END()
}; };
@ -72,6 +72,7 @@ static cfg_opt_t sec_library[] =
CFG_STR("name_audiobooks", "Audiobooks", CFGF_NONE), CFG_STR("name_audiobooks", "Audiobooks", CFGF_NONE),
CFG_STR_LIST("artwork_basenames", "{artwork,cover,Folder}", CFGF_NONE), CFG_STR_LIST("artwork_basenames", "{artwork,cover,Folder}", CFGF_NONE),
CFG_STR_LIST("filetypes_ignore", "{.db,.ini}", 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_BOOL("itunes_overrides", cfg_false, CFGF_NONE),
CFG_STR_LIST("no_transcode", NULL, CFGF_NONE), CFG_STR_LIST("no_transcode", NULL, CFGF_NONE),
CFG_STR_LIST("force_transcode", NULL, CFGF_NONE), CFG_STR_LIST("force_transcode", NULL, CFGF_NONE),

View File

@ -63,6 +63,7 @@
#define F_SCAN_BULK (1 << 0) #define F_SCAN_BULK (1 << 0)
#define F_SCAN_RESCAN (1 << 1) #define F_SCAN_RESCAN (1 << 1)
#define F_SCAN_FAST (1 << 2)
struct deferred_pl { struct deferred_pl {
char *path; char *path;
@ -92,7 +93,7 @@ static struct stacked_dir *dirstack;
/* Forward */ /* Forward */
static void static void
bulk_scan(void); bulk_scan(int flags);
static int static int
push_dir(struct stacked_dir **s, char *path) 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); DPRINTF(E_LOG, L_SCAN, "Forcing full rescan, found force-rescan file: %s\n", file);
db_purge_all(); db_purge_all();
bulk_scan(); bulk_scan(F_SCAN_BULK);
return; return;
} }
@ -748,7 +749,10 @@ process_directory(char *path, int flags)
} }
if (S_ISREG(sb.st_mode)) 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)) else if (S_ISDIR(sb.st_mode))
push_dir(&dirstack, entry); push_dir(&dirstack, entry);
else else
@ -832,7 +836,7 @@ process_directories(char *root, int flags)
/* Thread: scan */ /* Thread: scan */
static void static void
bulk_scan(void) bulk_scan(int flags)
{ {
cfg_t *lib; cfg_t *lib;
int ndirs; int ndirs;
@ -868,7 +872,7 @@ bulk_scan(void)
continue; continue;
} }
process_directories(deref, F_SCAN_BULK); process_directories(deref, flags);
free(deref); free(deref);
@ -876,7 +880,7 @@ bulk_scan(void)
return; return;
} }
if (playlists) if (!(flags & F_SCAN_FAST) && playlists)
process_deferred_playlists(); process_deferred_playlists();
if (scan_exit) if (scan_exit)
@ -885,10 +889,15 @@ bulk_scan(void)
if (dirstack) if (dirstack)
DPRINTF(E_LOG, L_SCAN, "WARNING: unhandled leftover directories\n"); DPRINTF(E_LOG, L_SCAN, "WARNING: unhandled leftover directories\n");
DPRINTF(E_DBG, L_SCAN, "Purging old database content\n"); if (flags & F_SCAN_FAST)
db_purge_cruft(start); 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_songartistid();
db_files_update_songalbumid(); 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(); db_hook_post_scan();