return 0;
}
- strip.scan_dir(opt_path);
+ strip.scan_dir(opt_path, "");
}
var newest = new DateTime.now_local();
- newest = oldest.add_months(-1 * StripApplication.opt_age_newest);
+ newest = newest.add_months(-1 * StripApplication.opt_age_newest);
tspan = mailtime.difference(newest) / GLib.TimeSpan.DAY;
if (tspan > 0) {
GLib.debug("skip file is %d days newer than %d months", (int)tspan, StripApplication.opt_age_newest);
if (timez != 0) {
mailtime = new DateTime.from_unix_utc(timez);
this.created_date = mailtime.format("%Y-%m-%d %H:%M:%S");
+ GLib.debug("Time is %s",this.created_date);
// if it's not mailfort we can use that date to determine where to store it...
if (!StripApplication.opt_scan_mailfort) {
this.created_dir = mailtime.format("%Y/%m/%d");
}
+ } else {
+ GLib.debug("Could not read time from headers?");
}
}
var oldest = new DateTime.now_local();
oldest = oldest.add_months(-1 * StripApplication.opt_age_oldest);
- var rtspan = mailtime.difference(oldest) / GLib.TimeSpan.DAY;
+ var rtspan = oldest.difference(oldest) / GLib.TimeSpan.DAY;
if (rtspan < 0) {
GLib.debug("skip(2) file is %d days older than %d months", (int)rtspan, StripApplication.opt_age_oldest);
return;
}
var newest = new DateTime.now_local();
- newest = oldest.add_months(-1 * StripApplication.opt_age_newest);
+ newest = newest.add_months(-1 * StripApplication.opt_age_newest);
rtspan = mailtime.difference(newest) / GLib.TimeSpan.DAY;
if (rtspan > 0) {
GLib.debug("skip(2) file is %d days newer than %d months : %s", (int)rtspan, StripApplication.opt_age_newest,
- mailtime.format("%Y-%m-%d %H:%i:%s"));
+ mailtime.format("%Y-%m-%d %H:%M:%S"));
return;
}
}
- public void scan_dir(string path)
+ public void scan_dir(string basepath, string subpath)
{
- var f = File.new_for_path(path);
+
+ // 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 newest = new DateTime.now_local();
+ newest = newest.add_months(-1 * StripApplication.opt_age_newest);
+
+ GLib.debug("Checking directory %s is newer than min: %d/%d/%d", subpath, newest.get_year() , newest.get_month(), newest.get_day_of_month() );
+
+ if (year > newest.get_year()) {
+ GLib.debug("Skip directory %s is newer than min year: %d", subpath, newest.get_year());
+ return;
+ }
+ if (year == newest.get_year() && month > newest.get_month()) {
+ GLib.debug("Skip directory %s is newer than min year: %d/%d", subpath, newest.get_year() , newest.get_month() );
+ return;
+ }
+ if (year == newest.get_year() && month == newest.get_month() && day > newest.get_day_of_month()) {
+ GLib.debug("Skip directory %s is newer than min year: %d/%d/%d", subpath, newest.get_year() , newest.get_month(), newest.get_day_of_month() );
+ return;
+ }
+
+
+
+ }
+
+
+ var f = File.new_for_path(basepath + subpath);
FileEnumerator file_enum;
var cancellable = new Cancellable ();
try {
}
// other files to ignore?
- this.scan_file(path , next_file.get_display_name());
+ this.scan_file(basepath + subpath , next_file.get_display_name());
if(this.has_replaced) {
- this.report_state("After scanning %s/%s".printf(path , next_file.get_display_name()));
+ this.report_state("After scanning %s/%s".printf(basepath + subpath , next_file.get_display_name()));
}
continue;
}
}
- var sp = path+"/"+next_file.get_display_name();
+ var sp = subpath+"/"+next_file.get_display_name();
// skip modules.
//print("got a file : " + sp);
next_file = null;
- this.scan_dir(sp);
+ this.scan_dir(basepath,sp);
}