{ "foreground", no_argument, 0, 'f' },
{ "log", required_argument, 0, 'l' },
{ "pidfile", required_argument, 0, 'P' },
- { "no-initial-rescan", no_argument, 0, 'N' },
{ "wide-open", no_argument, 0, 'w' },
{ "syslog", no_argument, 0, 's' },
{ 0, 0, 0, 0 }
int main(int argc, char **argv) {
int n, background = 1, logsyslog = 0;
const char *pidfile = 0;
- int initial_rescan = 1;
set_progname(argv);
mem_init();
case 'd': debugging = 1; break;
case 'f': background = 0; break;
case 'P': pidfile = optarg; break;
- case 'N': initial_rescan = 0; break;
case 's': logsyslog = 1; break;
case 'w': wideopen = 1; break;
default: fatal(0, "invalid option");
if(ev_signal(ev, SIGTERM, handle_sigterm, 0)) fatal(0, "ev_signal failed");
/* ignore SIGPIPE */
signal(SIGPIPE, SIG_IGN);
- /* start a rescan straight away */
- if(initial_rescan) {
+ /* start a rescan straight away if this is a new installation */
+ if(!trackdb_existing_database) {
trackdb_rescan(0/*ev*/);
/* No ev -> the rescan will block. Since we called reconfigure() already
* any clients will also be forced to block. */
const struct cache_type cache_files_type = { 86400 };
unsigned long cache_files_hits, cache_files_misses;
+/** @brief Set by trackdb_open() */
+int trackdb_existing_database;
+
/* setup and teardown ********************************************************/
static const char *home; /* home had better not change */
* - @p TRACKDB_OPEN_FOR_UPGRADE, if this is disorder-dbupgrade
*/
void trackdb_open(int flags) {
- int newdb, err;
+ int err;
pid_t pid;
/* sanity checks */
/* This doesn't make any sense */
fatal(0, "database is already at current version");
}
- newdb = 0;
+ trackdb_existing_database = 1;
} else {
if(flags & TRACKDB_OPEN_FOR_UPGRADE) {
/* Cannot upgrade a new database */
fatal(0, "cannot upgrade a database that does not exist");
}
/* This is a brand new database */
- newdb = 1;
+ trackdb_existing_database = 0;
}
/* open the databases */
trackdb_tracksdb = open_db("tracks.db",
trackdb_globaldb = open_db("global.db", 0, DB_HASH, DB_CREATE, 0666);
trackdb_noticeddb = open_db("noticed.db",
DB_DUPSORT, DB_BTREE, DB_CREATE, 0666);
- if(newdb) {
+ if(!trackdb_existing_database) {
/* Stash the database version */
char buf[32];