Branch: Tag:

2001-08-14

2001-08-14 18:30:16 by Johan Schön <js@opera.com>

Fixed bug: add_uri could add duplicate entries to the queue. Now also empties the cache when running clear().

Rev: lib/modules/Search.pmod/Queue.pmod/MySQL.pike:1.4

34:      static void perhaps_create_table( )   { -  catch { +     db->query(   #" -  create table "+table+#" ( +  create table IF NOT EXISTS "+table+#" (    uri blob not null,    uri_md5 char(32) not null default '',    template varchar(255) not null default '',    md5 char(32) not null default '',    recurse tinyint not null,    stage tinyint not null, -  INDEX uri_ind (uri_md5), +  UNIQUE(uri_md5),    INDEX stage (stage)    ) -  " -  ); -  }; +  ");   }      mapping hascache = ([]);
80:    rpath=rpath[sizeof(index)..];    r->path=reverse(rpath);    -  if( force || (check_link(uri, allow, deny) && !has_uri( r ) )) +  if( (force || (check_link(uri, allow, deny))) && !has_uri( r ) ) +  { +  mixed err = catch(    db->query( "insert into "+table+    " (uri,uri_md5,recurse,template) values (%s,%s,%d,%s)",    string_to_utf8((string)r), -  to_md5((string)r), recurse, (template||"") ); +  to_md5((string)r), recurse, (template||"") ) ); +  if(err) +  { +  werror("Error inserting %s into queue.\n", (string)r); +  werror("hascache: %O\n", hascache); +  throw(err);    } -  +  } + }      void set_md5( Standards.URI uri, string md5 )   {
192:      void clear()   { +  hascache = ([ ]);    db->query("delete from "+table);   }