src/strip.vala
[app.mailtrimmer] / src / strip.vala
index e472d6b..6cc604f 100644 (file)
@@ -661,7 +661,7 @@ public class Strip : GLib.Object {
                        oldest = oldest.add_months(-1 * StripApplication.opt_age_oldest);
                        var tspan = mailtime.difference(oldest) / GLib.TimeSpan.DAY;
 
-                       if (tspan > 0) {
+                       if (tspan < 0) {
                                GLib.debug("skip file is %d days older than %d months", (int)tspan, StripApplication.opt_age_oldest);
                                return;
                        }
@@ -864,6 +864,35 @@ public class Strip : GLib.Object {
     
     public void scan_dir(string basepath, string subpath)
     {
+        
+        // determine if path is to old to scan..
+        if (subpath.length > 0 && StripApplication.opt_scan_mailfort) {
+                       var year =  int.parse(subpath.substring(1,4));  // "/2000"
+                       var month = subpath.length > 5 ? int.parse(subpath.substring(6,2)) : 999; // "/2000/12"                 
+                       var day = subpath.length > 8 ? int.parse(subpath.substring(9,2)) : 999; // "/2000/12/01"                        
+               
+               var oldest = new  DateTime.now_local();
+                       oldest = oldest.add_months(-1 * StripApplication.opt_age_oldest);
+                       
+                       GLib.debug("Checking directory %s is older than min: %d/%d/%d", subpath, oldest.get_year() , oldest.get_month(), oldest.get_day_of_month() );                                   
+                       
+                       if (year < oldest.get_year()) {
+                               GLib.debug("Skip directory %s is older than min year: %d", subpath, oldest.get_year());
+                               return;
+                       }
+                       if (year == oldest.get_year() &&  month < oldest.get_month()) {
+                               GLib.debug("Skip directory %s is older than min year: %d/%d", subpath, oldest.get_year() , oldest.get_month() );
+                               return;
+                       }
+               if (year == oldest.get_year() &&  month == oldest.get_month() && day < oldest.get_day_of_month()) {
+                               GLib.debug("Skip directory %s is older than min year: %d/%d/%d", subpath, oldest.get_year() , oldest.get_month(), oldest.get_day_of_month() );          
+                               return;
+                       }
+                
+               
+        }
+        
+        
         var f = File.new_for_path(basepath + subpath);
                FileEnumerator file_enum;
         var cancellable = new Cancellable ();