#include <sys/wait.h>
#include <string.h>
#include <syslog.h>
+#include <time.h>
#include "configuration.h"
#include "syscalls.h"
const struct collection *c = cs->c;
const char *path = kvp_get(data, "_path");
char buffer[20];
- int err;
- long n;
+ int err, n;
+ long length;
if(aborted()) return EINTR;
D(("rechecking %s", track));
/* make sure we know the length */
if(!kvp_get(data, "_length")) {
D(("recalculating length of %s", track));
- n = tracklength(track, path);
- if(n > 0) {
- byte_snprintf(buffer, sizeof buffer, "%ld", n);
- kvp_set(&data, "_length", buffer);
- if((err = trackdb_putdata(trackdb_tracksdb, track, data, tid, 0)))
- return err;
- ++cs->nlength;
+ for(n = 0; n < config->tracklength.n; ++n)
+ if(fnmatch(config->tracklength.s[n].s[0], track, 0) == 0)
+ break;
+ if(n >= config->tracklength.n)
+ error(0, "no tracklength plugin found for %s", track);
+ else {
+ length = tracklength(config->tracklength.s[n].s[1], track, path);
+ if(length > 0) {
+ byte_snprintf(buffer, sizeof buffer, "%ld", length);
+ kvp_set(&data, "_length", buffer);
+ if((err = trackdb_putdata(trackdb_tracksdb, track, data, tid, 0)))
+ return err;
+ ++cs->nlength;
+ }
}
}
return 0;
*/
}
+/** @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;
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;
do_all(rescan_collection);
/* Check that every track still exists */
recheck_collection(0);
+ /* Expire noticed.db */
+ expire_noticed();
}
else {
/* Rescan specified collections */