factor reap() out of SqliteTable constructor
authoradam <adam@megacz.com>
Sun, 15 Jul 2007 21:54:19 +0000 (21:54 +0000)
committeradam <adam@megacz.com>
Sun, 15 Jul 2007 21:54:19 +0000 (21:54 +0000)
darcs-hash:20070715215419-5007d-b25e30acb13e48c369f3499d82df22c491b8c9e0.gz

src/org/ibex/mail/Graylist.java
src/org/ibex/mail/SqliteJdbcMailbox.java
src/org/ibex/mail/SqliteTable.java
src/org/ibex/mail/Whitelist.java

index 3754c62..e529995 100644 (file)
@@ -14,9 +14,8 @@ public class Graylist extends SqliteTable {
               new String[] {
                   "create table if not exists 'whitelist' (ip unique)",
                   "create table if not exists 'graylist' (ip,fromaddr,toaddr,date, primary key(ip,fromaddr,toaddr))"
-              },
-              "graylist",
-              "date");
+              });
+        reap("graylist", "date");
     }
 
     public synchronized void addWhitelist(InetAddress ip) {
index 3ae5165..5fc3621 100644 (file)
@@ -21,7 +21,7 @@ public class SqliteJdbcMailbox extends Mailbox.Default {
             Class.forName("org.sqlite.JDBC");
             conn = DriverManager.getConnection("jdbc:sqlite:"+filename);
             conn.prepareStatement("create virtual table if not exists "+
-                                  "'mail' using FTS1("+columns+",PRIMARY KEY(messageid_))").executeUpdate();
+                                  "'mail' using FTS2("+columns+",PRIMARY KEY(messageid_))").executeUpdate();
         }
         catch (SQLException e) { throw new RuntimeException(e); }
         catch (ClassNotFoundException e) { throw new RuntimeException(e); }
index 98950f6..4d32c90 100644 (file)
@@ -27,11 +27,10 @@ public class SqliteTable {
         conn.prepareStatement("PRAGMA cache_size="+Math.ceil(kilobytes/1.5)+";").executeUpdate();
     }
 
-    public SqliteTable(String filename, String[] tables, String reapTable, String reapColumn) {
-        this(filename, tables, false, reapTable, reapColumn);
+    public SqliteTable(String filename, String[] tables) {
+        this(filename, tables, false);
     }
-    public SqliteTable(String filename, String[] tables, boolean fastButDangerous,
-                       String reapTable, String reapColumn) {
+    public SqliteTable(String filename, String[] tables, boolean fastButDangerous) {
         this.filename = filename;
         try {
             Class.forName("org.sqlite.JDBC");
@@ -46,6 +45,11 @@ public class SqliteTable {
         }
         catch (SQLException e) { throw new RuntimeException(e); }
         catch (ClassNotFoundException e) { throw new RuntimeException(e); }
+    }
+
+    protected void reap(String reapTable, String reapColumn) {
+        if (this.reapTable != null || this.reapColumn != null)
+            throw new RuntimeException("reapTable/reapColumn already set");
         this.reapTable = reapTable;
         this.reapColumn = reapColumn;
         if (reapTable != null && reapColumn != null)
index 1d76bfc..5922dc3 100644 (file)
@@ -20,9 +20,8 @@ public class Whitelist extends SqliteTable {
                   "create table if not exists 'whitelist' (email)",
                   "create table if not exists 'pending' (spamid,email,message,date)"
               },
-              true,
-              "pending",
-              "date");
+              true);
+        reap("pending", "date");
     }
 
     public boolean handleRequest(org.ibex.net.Connection c) {