chiark / gitweb /
implement expiry of newly added tracks list
[disorder] / server / rescan.c
index 1171943467af0e0ec62c0008e96b72a0b0cfb9e5..53c566c1b977509959c1427597b257b65a9c2021 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/wait.h>
 #include <string.h>
 #include <syslog.h>
+#include <time.h>
 
 #include "configuration.h"
 #include "syscalls.h"
@@ -303,6 +304,14 @@ static void do_all(void (*fn)(const struct collection *c)) {
    */
 }
 
+/** @brief Expire noticed.db */
+static void expire_noticed(void) {
+  time_t now;
+
+  time(&now);
+  trackdb_expire_noticed(now - config->noticed_history * 86400);
+}
+
 int main(int argc, char **argv) {
   int n;
   struct sigaction sa;
@@ -325,7 +334,7 @@ int main(int argc, char **argv) {
     openlog(progname, LOG_PID, LOG_DAEMON);
     log_default = &log_syslog;
   }
-  if(config_read()) fatal(0, "cannot read configuration");
+  if(config_read(0)) fatal(0, "cannot read configuration");
   xnice(config->nice_rescan);
   sa.sa_handler = signal_handler;
   sa.sa_flags = SA_RESTART;
@@ -340,6 +349,8 @@ int main(int argc, char **argv) {
     do_all(rescan_collection);
     /* Check that every track still exists */
     recheck_collection(0);
+    /* Expire noticed.db */
+    expire_noticed();
   }
   else {
     /* Rescan specified collections */