chiark / gitweb /
find_track_root() now issues a log message if it finds a track outside
authorrjk@greenend.org.uk <>
Sat, 7 Jul 2007 15:07:09 +0000 (16:07 +0100)
committerrjk@greenend.org.uk <>
Sat, 7 Jul 2007 15:07:09 +0000 (16:07 +0100)
any collection.  Should make it clearer what's going on if something
believes the answer and crashes.

track_to_words() now includes a bodge for such tracks to avoid a
crash.  Ultimately the answer is to expunge such tracks from the
database but while my db is in a bizarre state it's worth making the
code a bit more robust.

lib/trackname.c
server/trackdb.c

index 7a891b7e658df5ba21f8e437b361f05e2e7a2bfb..cef77b85ee6ca5ad71206f823b2c6cadf57fa6ef 100644 (file)
@@ -44,7 +44,10 @@ const char *find_track_root(const char *track) {
        && track[l] == '/')
       break;
   }
-  if(n >= config->collection.n) return 0;
+  if(n >= config->collection.n) {
+    error(0, "found track in no collection '%s'", track);
+    return 0;
+  }
   return config->collection.s[n].root;
 }
 
index be1aea417a7bd6be6edc681ded10986e4d8567ab..ae3a7e268571b68fa4323b3a035fd91cc88336c8 100644 (file)
@@ -491,9 +491,12 @@ static char **track_to_words(const char *track,
   struct vector v;
   char **w;
   int nw;
+  const char *rootless = track_rootless(track);
 
+  if(!rootless)
+    rootless = track;                   /* bodge */
   vector_init(&v);
-  if((w = words(casefold(strip_extension(track_rootless(track))), &nw)))
+  if((w = words(casefold(strip_extension(rootless)), &nw)))
     vector_append_many(&v, w, nw);
 
   for(; p; p = p->next)