src/strip.vala
[app.mailtrimmer] / src / strip.vala
index 743f981..cb3e2c7 100644 (file)
@@ -370,7 +370,7 @@ public class Strip : GLib.Object {
        
        // initialize it with known data..
        // that should wipe out dupes.
-       var matches = this.execute("SELECT count(id) as nid FROM Attachment WHERE id = %d".printf(
+       var matches = this.execute("SELECT id   FROM Attachment WHERE id = %d".printf(
                        int.parse(sid)));  
 
                 
@@ -455,7 +455,7 @@ public class Strip : GLib.Object {
                
 
       
-               this.query("""
+               this.execute("""
                       
                       
                                INSERT INTO Attachment  (  
@@ -476,7 +476,8 @@ public class Strip : GLib.Object {
                                    mime_size ,
                                    filesize,
                                    
-                                   checksum
+                                   checksum,
+                                   created
 
                                ) VALUES (
                                        %d,  -- id
@@ -487,42 +488,40 @@ public class Strip : GLib.Object {
                                    '%s',  -- mimetype
                                    
                                    '%s', -- stored file anme
-                                   '',
+                                   '', -- charset
                                    'attachment',
                                    0,
                                    0,
                                    0,
                                    %d, -- size
                                    %d, -- size
-                                   '%s' -- checkum
-
-                               )"
+                                   
+                                   '%s', -- checkum
+                                       '%s' -- created:
+                               )
                       
                       
                      """.printf(
                                id,
                                      this.mysql_escape(this.active_message_exim_id),
-                                     this.mysql_escape(filename),                                                            
-                                 this.mysql_escape(mime_type),                                                       
-                                 this.mysql_escape(file_path),                                                       
-                             file_size
-                     file_size
+                                     this.mysql_escape(filename),
+                                 this.mysql_escape(mime_type),
+                                 this.mysql_escape(file_path),
+                                       file_size,
+                                     file_size,
                                      this.mysql_escape(chksum),
-
-
-                                     file_size
+                                       this.created_date
                         ));
-                        
+             // this is done to fix the queue_id or maillog_id ??
                 this.query("""
                  SELECT attachment_update(
                       %d, -- in_id INT(11),
-                      '%s', -- in_mime_type varchar(255),
+                                               '', -- mime type
                       '%s', -- in_created DATETIME,
                       '%s' -- in_mailfort_sig varchar(64)
                  )
              """.printf(
-                               id,
-                       "", // this will be ignored..
+                               id, 
                                this.created_date,
                                this.mysql_escape(this.active_message_x_mailfort_sig)
              
@@ -692,7 +691,13 @@ public class Strip : GLib.Object {
     {
            return this.real_query(false, str);
     }
-    public string real_query(bool need_return, string str)
+    /**
+    * need_return 
+    0 = no
+    1 = yes
+    -1 = don't try.
+    */
+    public string real_query(int need_return, string str)
     {
                GLib.debug("Before Query : %u  : %s\n", this.mysql.errno(), this.mysql.error());
 
@@ -710,7 +715,9 @@ public class Strip : GLib.Object {
                                Posix.exit(1);
                }
                
-
+               if (need_return == -1) {
+                       return '';
+               }
         var rs = mysql.use_result();
         
         //GLib.debug("got %d rows", (int) rs.num_rows());
@@ -723,7 +730,7 @@ public class Strip : GLib.Object {
                        ret = row[0];
                
                }
-               if (!need_return) {
+               if (need_return == 0) {
                if (StripApplication.opt_debug_sql) {
                                GLib.debug("got %s", got_row ? "=Nothing=" : ret);
                        }