chiark / gitweb /
suppress initial rescan completely, except for fresh installs
authorRichard Kettlewell <rjk@greenend.org.uk>
Tue, 4 Dec 2007 19:03:05 +0000 (19:03 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Tue, 4 Dec 2007 19:03:05 +0000 (19:03 +0000)
server/disorderd.c
server/trackdb.c
server/trackdb.h

index 758907cbd0ac4370fe99ad9e6729191ded725f43..b8f80109d86e557d2676ffb5497616675a018e02 100644 (file)
@@ -71,7 +71,6 @@ static const struct option options[] = {
   { "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 }
@@ -207,7 +206,6 @@ static void fix_path(void) {
 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();
@@ -223,7 +221,6 @@ int main(int argc, char **argv) {
     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");
@@ -288,8 +285,8 @@ int main(int argc, char **argv) {
   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. */
index bc526caad6acff31d0e952c028df74d0f75f0035..c275f3cfcecd9e3290d69b5624f4e5b89127bd3e 100644 (file)
@@ -75,6 +75,9 @@ static int trackdb_expire_noticed_tid(time_t earliest, DB_TXN *tid);
 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 */
@@ -306,7 +309,7 @@ static DB *open_db(const char *path,
  * - @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 */
@@ -359,14 +362,14 @@ void trackdb_open(int flags) {
       /* 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",
@@ -379,7 +382,7 @@ void trackdb_open(int flags) {
   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];
 
index 3cce6a5cced1ab970fb0404a2f1fea40f620ca28..c6a5897577b2f59786001c66425d94e394dddb6f 100644 (file)
@@ -64,6 +64,8 @@ void trackdb_open(int flags);
 void trackdb_close(void);
 /* open/close track databases */
 
+extern int trackdb_existing_database;
+
 char **trackdb_stats(int *nstatsp);
 /* return a list of database stats */