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

@@ -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),

View File

@@ -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();