src/strip.vala
[app.mailtrimmer] / src / strip.vala
index 46623eb..590bbb7 100644 (file)
@@ -3,7 +3,7 @@
  ** check left to do:  
   - range scans on maildir
   - see how replacing the links works in the resulting email via thunderbird etc..
-  
+  - some checksum issues (see dupelicates?? suspect 0byte issues?)  -- seems ok now?
  
 
 
@@ -557,7 +557,10 @@ public class Strip : GLib.Object {
                        }
                        GLib.debug("Creating file %s", target_fn);
                        if (!FileUtils.test (target_fn, FileTest.EXISTS)) {
-                               Posix.link(fn, target_fn);
+                               var from = File.new_for_path (fn);
+                               var to =  File.new_for_path (target_fn);
+                               from.copy(to, 0, null);
+
                        }
                } else { 
                        GLib.debug("Skipping extraction %s", target_fn);
@@ -605,7 +608,7 @@ public class Strip : GLib.Object {
                
                }
                if (!need_return) {
-                       return "";
+                       return got_row ? "" : ret;
                }
                if (!got_row) {
                         GLib.debug("ERROR : no rows returned");
@@ -842,6 +845,7 @@ public class Strip : GLib.Object {
         GLib.debug("finished writing output %d", file_size);
 
         //
+        outstream = null;
         
          
        this.used_space_after += file_size;
@@ -850,12 +854,17 @@ public class Strip : GLib.Object {
        if (StripApplication.opt_is_replacing) {
                Posix.unlink(path +"/" + name);         
                GLib.debug("copy tmp file %s to %s" , tmpfile, path +"/" + name);               
-               Posix.link(tmpfile, path +"/" + name);
-               Posix.unlink(tmpfile);
-               var nf = File.new_for_path(path +"/" + name);
+               
+               // link will not work, as we are doing it accross file systems
+                       var from = File.new_for_path (tmpfile);
+                       var nf =  File.new_for_path (path +"/" + name);
+                       from.copy(nf, 0, null);
+                       
+
                var newfileinfo = nf.query_info(GLib.FileAttribute.TIME_MODIFIED,GLib.FileQueryInfoFlags.NONE,null);
                newfileinfo.set_modification_time(mod_time);
                nf.set_attributes_from_info(newfileinfo,FileQueryInfoFlags.NONE);
+               Posix.unlink(tmpfile);
                }
        this.processed++;