src/strip.vala
[app.mailtrimmer] / src / strip.vala
index 4e65238..404c132 100644 (file)
@@ -368,6 +368,18 @@ public class Strip : GLib.Object {
                return;
        }
        
+       // 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(
+                       int.parse(sid)));  
+                GLib.error("Got Matches :%s", matches);
+                
+               if (matches=="0") {      
+                  GLib.error("Failed to find id  :%s", sid);
+                  return;
+               }
+       
+       
        // initialize it with known data..
        // that should wipe out dupes.
        var filesize = this.execute("SELECT filesize FROM Attachment WHERE id = %d".printf(
@@ -594,7 +606,7 @@ public class Strip : GLib.Object {
                
                
        
-       var rc=  this.mysql.query(str);         
+       var rc=  this.mysql.query(str); 
        if ( rc != 0 ) {
 
                    GLib.debug("ERROR %u: Query failed: %s\n", this.mysql.errno(), this.mysql.error());
@@ -604,6 +616,8 @@ public class Strip : GLib.Object {
 
         var rs = mysql.use_result();
         
+        //GLib.debug("got %d rows", (int) rs.num_rows());
+        
         var got_row = false;
                string[] row;
                string ret = "";
@@ -613,14 +627,20 @@ public class Strip : GLib.Object {
                
                }
                if (!need_return) {
+               if (StripApplication.opt_debug_sql) {
+                               GLib.debug("got %s", got_row ? "=Nothing=" : ret);
+                       }
                        return got_row ? "" : ret;
                }
                if (!got_row) {
+
                         GLib.debug("ERROR : no rows returned");
                        Posix.exit(1);
                        return "";
                }
-               GLib.debug("got %s", ret);
+       if (StripApplication.opt_debug_sql) {
+                       GLib.debug("got %s", ret);
+               }
                return ret;
                
                 
@@ -969,17 +989,21 @@ public class Strip : GLib.Object {
                 continue;
             }
             
-
+            var ds = next_file.get_display_name();
             if (next_file.get_file_type() != FileType.DIRECTORY) {
                 
-                if (next_file.get_display_name()[0] == ',') {
+                
+                
+                if (ds[0] == ',') {
                        continue;
                }
                // other files to ignore?
-                
-                this.scan_file(basepath + subpath , next_file.get_display_name());
+                if (Regex.match_simple (".tgz$", ds)) {
+                       continue;
+               }
+                this.scan_file(basepath + subpath , ds);
                                if(this.has_replaced) {
-                                this.report_state("After scanning %s/%s".printf(basepath + subpath , next_file.get_display_name()));
+                                this.report_state("After scanning %s/%s".printf(basepath + subpath , ds));
                        }
                 continue;
             }
@@ -990,7 +1014,7 @@ public class Strip : GLib.Object {
 
 
         
-            var ds = next_file.get_display_name();
+
             // not really needed?? - we are storing attachments in a seperate location now...
             if (ds[0] == '.') {
                 next_file = null;