4 a) our mailfort email database
5 point it at the top directory, containing YEAR/MONTH/DAY.... directories.
6 scan each file (over a year old...)
7 extract out the attachment, and replace with HTML
8 DATABASE? - mysql or sqlite? -
9 filesize / name / date / checksum / mimetype -- into mailfort should be OK.
10 b) the imap user emails
11 loop through user's directories
12 check age of email .. over 1 years..
13 ?? how to prevent 'repeat' scanning of emails?
14 ??? hidden '.' files containing last scan date?
16 check if file exists in our DB.. - replace the link...
17 otherwise generate a file. + add to DB...
22 -> URL -> redirect to correct server
25 More notes on our Mailfort DB sync:
26 * some of these attachments are already in the database...
27 - so we need to update the DB..
28 - probably worth putting the code in a stored procedure..
31 * first scan (and extract)
32 * rescan (as I messed up the first time - fix the DB...)
33 * email scan - attachments might not have related messages.
36 - {id} attachment_init(
41 // creates or returns id (can look for existing messages?
42 // can do a merge?? - copy 'old' record data into 'new'.... "prefer checksummed"
49 {created} // message date..
54 attachment_update_store(
62 // valac --pkg gmime --vapi
65 // http://www.fromdual.com/mysql-vala-program-example << check mysql if this does not work.
67 valac -g --vapidir=. --thread strip.vala --vapidir=../vapi \
68 --pkg glib-2.0 --pkg mysql --pkg gio-2.0 --pkg posix --pkg gmime-2.6 \
69 --Xcc=-lmysqlclient -v \
73 public class StripApplication : GLib.Application {
75 public static string? opt_path = null;
76 public static string? opt_file = null;
77 public static string? opt_target_path = null;
78 public static string? opt_db_host = "127.0.0.1";
79 public static string? opt_db_name = null;
80 public static string? opt_db_user = null;
81 public static string? opt_db_pass = null;
83 public static int opt_limit = -1;
85 public static int opt_min_age = 6;
88 public static bool opt_is_extracting = false;
89 public static bool opt_is_replacing = false;
90 public static bool opt_scan_imap = false;
91 public static bool opt_scan_mailfort = false;
92 public static bool opt_dump = false;
93 public static bool opt_debug = false;
95 public static bool opt_debug_sql = false;
96 public static string? opt_replace_link = null;
99 public const GLib.OptionEntry[] options = {
101 { "debug", 0, 0, OptionArg.NONE, ref opt_debug, "show debug messages for components", null },
102 { "debug-sql", 0, 0, OptionArg.NONE, ref opt_debug_sql, "debug the SQL statements", null },
104 { "path", 0, 0, OptionArg.STRING, ref opt_path, "Directory where email to be parsed is", null },
105 { "file", 0, 0, OptionArg.STRING, ref opt_file, "A specific file to be parsed", null },
107 { "target-path", 0, 0, OptionArg.STRING, ref opt_target_path, "Directory where attachments are to be put", null },
109 { "link", 0, 0, OptionArg.STRING, ref opt_replace_link, "url for the replement link: eg. http://www.mysite.com/xxxx/%s", null },
111 { "host", 0, 0, OptionArg.STRING, ref opt_db_host, "Mysql host (default localhost)", null },
112 { "name", 0, 0, OptionArg.STRING, ref opt_db_name, "Mysql database name REQUIRED", null },
113 { "user", 0, 0, OptionArg.STRING, ref opt_db_user, "Mysql database user REQUIRED", null },
114 { "pass", 0, 0, OptionArg.STRING, ref opt_db_pass, "Mysql database password (default empty)", null },
116 { "extract", 0, 0, OptionArg.NONE, ref opt_is_extracting, "Should attachments be extracted (default NO)", null },
117 { "replace", 0, 0, OptionArg.NONE, ref opt_is_replacing, "Should attachments be replaced (default NO)", null },
118 { "dump", 0, 0, OptionArg.NONE, ref opt_dump, "Print the replaced mail contents to stdout", null },
120 { "limit", 0, 0, OptionArg.INT, ref opt_limit, "stop after X number of messages with attachments have been processed", null },
121 { "min-age", 0, 0, OptionArg.INT, ref opt_min_age, "minimum age of messages (default is 6 months)", null },
123 { "scan-imap", 0, 0, OptionArg.NONE, ref opt_scan_imap, "scan an imap tree", null },
124 { "scan-mailfort", 0, 0, OptionArg.NONE, ref opt_scan_mailfort, "scan a mailfort tree", null },
127 public StripApplication( string[] args )
130 application_id: "org.roojs.mailstripper",
131 flags: ApplicationFlags.FLAGS_NONE
135 var opt_context = new GLib.OptionContext ("Mail Stripper");
139 opt_context.set_help_enabled (true);
140 opt_context.add_main_entries (options, null);
141 opt_context.parse ( ref args);
142 //opt_detach = !optx_no_detach;
146 // options that have to be set.. bee or hive... (or stop all)
147 if ((!opt_scan_mailfort && !opt_scan_imap) || (opt_scan_mailfort && opt_scan_imap)) {
148 stdout.printf ("You must specify the type of directory tree to scan - either imap or mailfort\n%s",
149 opt_context.get_help(true, null));
150 GLib.Process.exit(Posix.EXIT_FAILURE);
153 if ((opt_db_name == null || opt_db_name.length < 1 || opt_db_user == null || opt_db_user.length < 1)) {
154 stdout.printf ("You must specify the database name / user \n%s",
155 opt_context.get_help(true, null));
156 GLib.Process.exit(Posix.EXIT_FAILURE);
158 if ((opt_path == null || opt_path.length < 1) ) {
159 stdout.printf ("You must specify the scan start path\n%s",
160 opt_context.get_help(true, null));
161 GLib.Process.exit(Posix.EXIT_FAILURE);
163 if (opt_replace_link == null || (opt_replace_link.length < 1)) {
164 stdout.printf ("You must specify the link to use in the replacement \n%s",
165 opt_context.get_help(true, null));
166 GLib.Process.exit(Posix.EXIT_FAILURE);
168 if ((opt_is_replacing || opt_is_extracting ) && (opt_target_path == null || opt_target_path.length < 1)) {
169 stdout.printf ("You must specify a target path to put attachments\n%s",
170 opt_context.get_help(true, null));
171 GLib.Process.exit(Posix.EXIT_FAILURE);
175 } catch (GLib.OptionError e) {
176 stdout.printf ("error: %s\n", e.message);
177 stdout.printf ("Run '%s --help' to see a full list of available command line options.\n%s",
178 args[0], opt_context.get_help(true, null));
179 GLib.Process.exit(Posix.EXIT_FAILURE);
183 public static int main(string[] args)
186 var application = new StripApplication( args);
188 GLib.Log.set_always_fatal(LogLevelFlags.LEVEL_ERROR | LogLevelFlags.LEVEL_CRITICAL);
190 if (opt_debug || opt_debug_sql) {
191 GLib.Log.set_handler(null,
192 GLib.LogLevelFlags.LEVEL_DEBUG | GLib.LogLevelFlags.LEVEL_WARNING | GLib.LogLevelFlags.LEVEL_INFO,
200 if (StripApplication.opt_is_replacing) {
201 StripApplication.opt_is_extracting = true;
204 GLib.debug("scanning folder: %s", opt_path );
206 var strip = new Strip( opt_path );
209 strip.mysql = new Mysql.Database();
210 if (!strip.mysql.real_connect(
213 opt_db_pass == null ? "" : opt_db_pass, //passwd
215 3306, // not changable...?
219 stdout.printf("ERROR %u: Connection failed: %s\n",
220 strip.mysql.errno(), strip.mysql.error()
225 if (opt_file != null) {
226 strip.base_dir = opt_path;
227 strip.scan_file( GLib.Path.get_dirname(opt_file), GLib.Path.get_basename(opt_file));
231 strip.scan_dir(opt_path);
239 public class Strip : GLib.Object {
243 public string base_dir = "";
245 public Mysql.Database mysql;
249 uint64 used_space_before = 0;
250 uint64 used_space_after = 0;
253 public Strip(string base_dir)
255 this.base_dir = base_dir;
258 public void handle_part(GMime.Object parent, GMime.Object mime_obj)
260 if (mime_obj is GMime.Part) {
261 var p = (GMime.Part)mime_obj;
262 var ct = p.get_content_type();
263 var cd = p.get_content_disposition();
265 var sid = p.get_header("X-strip-id");
266 if (sid != null && sid.length > 0) {
267 this.update_attachment_db(p);
268 GLib.debug("Skip attachment replace - it's already been done");
272 if (cd == null || cd.get_disposition().down() != "attachment") {
275 if (ct.get_media_type() == "text") {
278 if (ct.to_string() == "application/pgp-encrypted") {
281 if (ct.to_string() == "application/pgp-keys") {
284 if (p.get_filename() == null) {
287 // print("got part %s\n", ct.to_string());
288 if (parent is GMime.Multipart) {
290 this.replace_attachment(((GMime.Multipart)parent), p);
298 if (mime_obj is GMime.Multipart) {
301 var mp = (GMime.Multipart)mime_obj;
302 //var ct = mp.get_content_type();
304 //print("got multi-part %s\n", ct.to_string());
305 for (var i = 0; i< mp.get_count(); i++) {
306 var mo = mp.get_part(i);
307 this.handle_part(mime_obj,mo);
309 // ((GMime.Multipart)mime_obj).foreach((sub_obj) => {
310 // Strip.handle_part(sub_obj);
318 if (mime_obj is GMime.MessagePart) {
319 var msg = ((GMime.MessagePart)mime_obj).get_message();
320 msg.foreach((subobj) => {
321 this.handle_part(msg,subobj);
324 //print("got message-part\n");
328 if (mime_obj is GMime.Message) {
329 var mp = ((GMime.Message) mime_obj).get_mime_part();
331 if (!(mp is GMime.Multipart)) {
332 //GLib.debug("get mimepart does not return a Multipart?");
336 var mpc = ((GMime.Multipart)mp).get_count();
338 //GLib.debug("Message has %d parts", mpc);
339 for (var i =0 ; i < mpc; i++) {
340 //GLib.debug("Getting part %d", i);
341 var submime_obj = ((GMime.Multipart)mp).get_part(i);
342 this.handle_part(mp,submime_obj);
344 print("got message??\n");
348 print("got something else\n");
352 public void update_attachment_db(GMime.Part attachment)
354 // only called when we have an sid...
355 var sid = attachment.get_header("X-strip-id");
356 if (sid == null || sid.length < 1) {
357 GLib.debug("Strange - update attachment db called ?");
361 // initialize it with known data..
362 // that should wipe out dupes.
363 var filesize = this.query("SELECT filesize FROM Attachment WHERE id = %d".printf(
365 if (int.parse(filesize) < 1) {
366 GLib.debug("Could not get filesize from id :%s = %s", sid,filesize);
371 var chksum = this.query("SELECT checksum FROM Attachment WHERE id = %d".printf(
374 var mime_filename = this.query("SELECT mime_filename FROM Attachment WHERE id = %d".printf(
384 this.mysql_escape(this.active_message_exim_id),
385 this.mysql_escape(chksum),
386 this.mysql_escape(mime_filename),
390 SELECT attachment_update(
391 %d, -- in_id INT(11),
392 '%s', -- in_mime_type varchar(255),
393 '%s', -- in_created DATETIME,
394 '%s' -- in_mailfort_sig varchar(64)
398 "", // this will be ignored..
400 this.mysql_escape(this.active_message_x_mailfort_sig)
404 this.mysql.store_result();
411 public void replace_attachment(GMime.Multipart parent, GMime.Part attachment)
413 var sid = attachment.get_header("X-strip-id");
414 if (sid != null && sid.length > 0) {
415 GLib.debug("Skip attachment replace - it's already been done");
419 var c = attachment.get_content_object();
421 var filename = attachment.get_filename().replace("/", "-").replace("\n", "").replace("\t", " ");
422 var fn = GLib.Environment.get_tmp_dir() +
423 "/"+ this.active_name + "."+ filename;
425 var outfile = new GMime.StreamFile.for_path(fn, "w");
426 outfile.set_owner(true);
427 var file_size = (int) c.write_to_stream(outfile);
428 var chksum = this.md5_file(fn);
432 if (file_size == 0) {
434 GLib.debug("ERROR - file size of write to stream returned 0?");
442 var mime_type= attachment.get_content_type().to_string();
443 // at this point we have to do our database magic...
444 //filesize / name / date / checksum / mimetype -- into mailfort should be OK.
446 var file_id = this.query("""
450 '%s', -- in_msgid VARCHAR(32),
451 '%s', -- in_checksum VARCHAR(64),
452 '%s', -- in_mime_filename varchar(255)
457 this.mysql_escape(this.active_message_exim_id),
459 this.mysql_escape( attachment.get_filename() ), // what is thsi is invalid?
464 if (file_id.length < 1) {
465 GLib.debug("ERROR - CALL to attachment_init failed");
471 if (int.parse(file_id) < 1) {
472 GLib.debug("ERROR - CALL to attachment_init failed - returned 0?");
479 GLib.debug("fn = %s, m5=%s, id= %s", filename, mime_type, this.active_message_id);
482 SELECT attachment_update(
483 %d, -- in_id INT(11),
484 '%s', -- in_mime_type varchar(255),
485 '%s', -- in_created DATETIME,
486 '%s' -- in_mailfort_sig varchar(64)
491 this.mysql_escape(mime_type),
493 this.mysql_escape(this.active_message_x_mailfort_sig)
495 this.mysql.store_result();
498 this.used_space_after += file_size;
502 if (StripApplication.opt_is_extracting) {
503 target_fn = StripApplication.opt_target_path + "/" + this.created_dir +"/"+ file_id + "-" + filename;
506 var stored = "/" + this.created_dir +"/"+ file_id + "-" + filename;
509 SELECT attachment_update_store(
510 %d, -- in_id INT(11),
511 '%s' -- in_store_filename varchar(255),
517 this.mysql_escape( stored)
520 var rep = new GMime.Part.with_type("text","html");
521 // we have to set up a redirect server - to redirect hpasite... to their internal service..
522 rep.set_filename(filename);
523 string txt = "<html><body>"+
524 "<a href=\"" + StripApplication.opt_replace_link + "/" +
525 file_id + "/" + this.created_dir + "/"+chksum+"/"+ GLib.Uri.escape_string( filename) +"\">" +
526 GLib.Uri.escape_string( filename) + // fixme needs html escaping...
530 rep.get_content_type().set_parameter("charset", "utf-8");
531 rep.set_header("X-strip-id", file_id);
532 rep.set_header("X-strip-content-name", filename);
533 rep.set_header("X-strip-path", this.created_dir + "/" + file_id + "-" + filename);
534 rep.set_header("X-strip-content-type", mime_type);
535 var stream = new GMime.StreamMem.with_buffer(txt.data);
536 var con = new GMime.DataWrapper.with_stream(stream,GMime.ContentEncoding.DEFAULT);
538 rep.set_content_object(con);
539 GLib.debug("Replacing Attachment with HTML");
540 parent.replace(parent.index_of(attachment), rep);
541 this.has_replaced = true;
543 if (StripApplication.opt_is_extracting && target_fn.length > 0) {
544 var dir = GLib.Path.get_dirname(target_fn);
545 if (!FileUtils.test (dir, FileTest.IS_DIR)) {
546 GLib.DirUtils.create_with_parents(dir, 0755);
548 GLib.debug("Creating file %s", target_fn);
549 if (!FileUtils.test (target_fn, FileTest.EXISTS)) {
550 Posix.link(fn, target_fn);
553 GLib.debug("Skipping extraction %s", target_fn);
560 public string query(string str)
562 return this.real_query(true, str);
564 public string execute(string str)
566 return this.real_query(false, str);
568 public string real_query(bool need_return, string str)
570 GLib.debug("Before Query : %u : %s\n", this.mysql.errno(), this.mysql.error());
573 if (StripApplication.opt_debug_sql) {
574 GLib.debug("SQL: %s\n", str);
579 var rc= this.mysql.query(str);
582 GLib.debug("ERROR %u: Query failed: %s\n", this.mysql.errno(), this.mysql.error());
587 var rs = mysql.use_result();
592 while( (row = rs.fetch_row()) != null) {
601 GLib.debug("ERROR : no rows returned");
605 GLib.debug("got %s", ret);
611 public string mysql_escape(string str)
613 unichar[] value_escaped = new unichar[str.length * 2 + 1];
614 this.mysql.real_escape_string ((string) value_escaped, str, str.length);
615 return (string) value_escaped;
618 public string md5_file(string fn) {
619 Checksum checksum = new Checksum (ChecksumType.MD5);
621 FileStream stream = FileStream.open (fn, "rb");
625 while ((size = stream.read (fbuf)) > 0) {
626 checksum.update (fbuf, size);
629 unowned string digest = checksum.get_string ();
633 string active_path = "";
634 string active_name = "";
635 string active_message_id = "";
636 string active_message_x_mailfort_sig = "";
637 string active_message_exim_id = "";
638 bool has_replaced = false;
639 string created_date = ""; // should be YYYY-mm-dd
640 string created_dir = ""; // should be YYY/mm/dd
642 public void scan_file(string path, string name)
644 GLib.debug("Scan: %s/%s", path,name);
646 this.has_replaced = false;
647 this.active_path = path;
648 this.active_name = name;
649 this.active_message_id = "";
651 DateTime mailtime = new DateTime.local();
652 if (StripApplication.opt_scan_mailfort) {
653 this.created_dir = this.active_path.substring(this.base_dir.length + 1 );
654 this.created_date = this.created_dir.replace("/", "-");
655 var bits = this.created_date.split("-");
656 mailtime = new DateTime.local(int.parse(bits[0]),int.parse(bits[1]),int.parse(bits[2]),0,0,0);
658 var oldest = new DateTime.now_local();
659 oldest.add_months(-1 * StripApplication.opt_min_age);
660 var tspan = mailtime.difference(oldest) / GLib.TimeSpan.DAY;
663 GLib.debug("skip file is %d days older than %d months", (int)tspan, StripApplication.opt_min_age);
670 var fileinfo = File.new_for_path(path +"/" + name)
671 .query_info(GLib.FileAttribute.STANDARD_SIZE+","+GLib.FileAttribute.TIME_MODIFIED
672 ,GLib.FileQueryInfoFlags.NONE,null);
673 var file_size = (int) fileinfo.get_size();
674 var mod_time = fileinfo.get_modification_time();
678 if (!StripApplication.opt_scan_mailfort) {
680 // it's a mail directory...
681 // use the last modification time? as the default...
682 mailtime = new DateTime.from_timeval_utc(mod_time);
683 this.created_dir = mailtime.format("/%Y/%m/%d");
684 this.created_date = mailtime.format("%Y-%m-%d %H:%M:%S");
687 // check on age of file...
693 this.used_space_before += file_size;
695 var stream = new GMime.StreamFs.for_path (path +"/" + name,Posix.O_RDONLY, 0);
696 //stream.set_owner(true);
697 var parser = new GMime.Parser.with_stream(stream);
698 var message = parser.construct_message();
700 if (message == null) {
701 GLib.debug("Could not parse file? %s/%s", path,name);
702 this.used_space_after += file_size;
707 // check : - is message over a year old?
708 // get various msg info..
709 this.active_message_id = message.get_message_id();
710 this.active_message_x_mailfort_sig = message.get_header("x-mailfort-sig");
711 var recvd = message.get_header("received");
712 this.active_message_exim_id = "";
713 if (recvd != null && recvd.length > 1) {
714 // GLib.debug("RECV: %s", recvd);
715 var lines = recvd.split("\t");
716 for (var i = 0; i < lines.length;i++) {
717 var bits = lines[i].strip().split(" ");
718 if (bits[0] == "id") {
719 this.active_message_exim_id = bits[1].replace(";","");
724 if (lines[i].contains(";")) {
725 var dbits = lines[i].strip().split(";");
726 var timez = GMime.utils_header_decode_date(dbits[1], null);
728 mailtime = new DateTime.from_unix_utc(timez);
729 this.created_date = mailtime.format("%Y-%m-%d %H:%M:%S");
730 // if it's not mailfort we can use that date to determine where to store it...
731 if (!StripApplication.opt_scan_mailfort) {
732 this.created_dir = mailtime.format("/%Y/%m/%d");
740 var oldest = new DateTime.now_local();
741 oldest.add_months(-1 * StripApplication.opt_min_age);
742 var rtspan = mailtime.difference(oldest) / GLib.TimeSpan.DAY;
745 GLib.debug("skip file is %d days older than %d months", (int)rtspan, StripApplication.opt_min_age);
753 GLib.debug("Message DATA:\n mid: %s\nmailfort: %s \nexim_id: %s",
754 this.active_message_id,
755 this.active_message_x_mailfort_sig,
756 this.active_message_exim_id
762 var mp = message.get_mime_part();
764 if (!(mp is GMime.Multipart)) {
765 //GLib.debug("get mimepart does not return a Multipart?");
766 this.used_space_after += file_size;
770 var mpc = ((GMime.Multipart)mp).get_count();
772 //GLib.debug("Message has %d parts", mpc);
773 for (var i =0 ; i < mpc; i++) {
774 //GLib.debug("Getting part %d", i);
775 var mime_obj = ((GMime.Multipart)mp).get_part(i);
776 this.handle_part(mp,mime_obj);
781 // stream.set_owner(false);
783 stream = null;//.close();
786 if (!this.has_replaced) {
787 this.used_space_after += file_size;
788 GLib.debug("skpping write file - no replacement occured");
792 GMime.Stream outstream = new GMime.StreamNull();
793 if (StripApplication.opt_is_replacing) {
795 tmpfile = GLib.Environment.get_tmp_dir() +"/" + name;
796 outstream = new GMime.StreamFile.for_path (tmpfile,"w");
797 ((GMime.StreamFile)outstream).set_owner(true);
799 if (StripApplication.opt_dump) {
800 outstream = new GMime.StreamMem();
803 file_size = (int) message.write_to_stream(outstream);
804 if (StripApplication.opt_is_replacing) {
805 ((GMime.StreamFile)outstream).set_owner(false);
807 if (StripApplication.opt_dump) {
808 var ua = ((GMime.StreamMem)outstream).get_byte_array().data;
809 print("%s\n", (string) ua);
814 GLib.debug("finished writing output %d", file_size);
819 this.used_space_after += file_size;
822 if (StripApplication.opt_is_replacing) {
823 Posix.unlink(path +"/" + name);
824 GLib.debug("copy tmp file %s to %s" , tmpfile, path +"/" + name);
825 Posix.link(tmpfile, path +"/" + name);
826 Posix.unlink(tmpfile);
827 var nf = File.new_for_path(path +"/" + name);
828 var newfileinfo = nf.query_info(GLib.FileAttribute.TIME_MODIFIED,GLib.FileQueryInfoFlags.NONE,null);
829 newfileinfo.set_modification_time(mod_time);
830 nf.set_attributes_from_info(newfileinfo,FileQueryInfoFlags.NONE);
834 if (StripApplication.opt_limit > -1 && this.processed >= StripApplication.opt_limit) {
835 GLib.debug("Reached replacement limit");
845 public void scan_dir(string path)
847 var f = File.new_for_path(path);
848 FileEnumerator file_enum;
849 var cancellable = new Cancellable ();
851 file_enum = f.enumerate_children(
852 FileAttribute.STANDARD_DISPLAY_NAME + "," + FileAttribute.STANDARD_TYPE,
853 FileQueryInfoFlags.NOFOLLOW_SYMLINKS, // FileQueryInfoFlags.NONE,
857 GLib.debug("Got error scanning dir? %s", e.message);
858 // FIXME - show error..
863 while (cancellable.is_cancelled () == false ) {
865 next_file = file_enum.next_file (cancellable);
867 GLib.debug("error getting next file? %s", e.message);
871 if (next_file == null) {
876 if (next_file.get_is_symlink()) {
882 if (next_file.get_file_type() != FileType.DIRECTORY) {
884 if (next_file.get_display_name()[0] == ',') {
887 // other files to ignore?
889 this.scan_file(path , next_file.get_display_name());
890 if(this.has_replaced) {
891 this.report_state("After scanning %s/%s".printf(path , next_file.get_display_name()));
897 //stdout.printf("Monitor.monitor: got file %s : type :%u\n",
898 // next_file.get_display_name(), next_file.get_file_type());
902 var ds = next_file.get_display_name();
903 // not really needed?? - we are storing attachments in a seperate location now...
908 if (ds == "attachments") {
913 var sp = path+"/"+next_file.get_display_name();
915 //print("got a file : " + sp);
926 void report_state(string msg)
928 // Saved: 2G Original 10G : 20%
929 GLib.debug("Saved : %s (%.1f%%) | Original %s | %s",
930 GLib.format_size(this.used_space_before - this.used_space_after),
931 100f * ((1f * (this.used_space_before - this.used_space_after)) / (this.used_space_before * 1f)),
932 GLib.format_size(this.used_space_before),