chiark / gitweb /
merge from disorder.dev
[disorder] / server / rescan.c
index 1c3eb58fbd3a156b70052f9b9e48a99477ddc0f7..b878929a82adc97812030d3a898322ec322ac3f8 100644 (file)
@@ -50,6 +50,7 @@
 #include "trackdb.h"
 #include "trackdb-int.h"
 #include "trackname.h"
+#include "unicode.h"
 
 static DB_TXN *global_tid;
 
@@ -151,6 +152,13 @@ static void rescan_collection(const struct collection *c) {
       error(0, "cannot convert track path to UTF-8: %s", path);
       continue;
     }
+    if(config->dbversion > 1) {
+      /* We use NFC track names */
+      if(!(track = utf8_compose_canon(track, strlen(track), 0))) {
+        error(0, "cannot convert track path to NFC: %s", path);
+        continue;
+      }
+    }
     D(("track %s", track));
     /* only tracks with a known player are admitted */
     for(n = 0; (n < config->player.n
@@ -341,7 +349,7 @@ int main(int argc, char **argv) {
     default: fatal(0, "invalid option");
     }
   }
-  if(!logsyslog) {
+  if(logsyslog) {
     openlog(progname, LOG_PID, LOG_DAEMON);
     log_default = &log_syslog;
   }
@@ -353,8 +361,8 @@ int main(int argc, char **argv) {
   xsigaction(SIGTERM, &sa, 0);
   xsigaction(SIGINT, &sa, 0);
   info("started");
-  trackdb_init(0);
-  trackdb_open();
+  trackdb_init(TRACKDB_NO_RECOVER);
+  trackdb_open(TRACKDB_NO_UPGRADE);
   if(optind == argc) {
     /* Rescan all collections */
     do_all(rescan_collection);