projects
/
app.mailtrimmer
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
31105d3
)
src/strip.vala
author
Alan Knowles
<alan@roojs.com>
Mon, 7 May 2018 01:27:18 +0000
(09:27 +0800)
committer
Alan Knowles
<alan@roojs.com>
Mon, 7 May 2018 01:27:18 +0000
(09:27 +0800)
src/strip.vala
patch
|
blob
|
history
diff --git
a/src/strip.vala
b/src/strip.vala
index
56076c0
..
28d3b9d
100644
(file)
--- a/
src/strip.vala
+++ b/
src/strip.vala
@@
-356,46
+356,50
@@
public class Strip : GLib.Object {
// initialize it with known data..
// that should wipe out dupes.
// initialize it with known data..
// that should wipe out dupes.
+ var filesize = this.query("SELECT filesize FROM Attachment WHERE id = %d;".printf(
+ int.parse(sid)));
+ if (int.parse(filesize) < 1) {
+ GLib.debug("Could not get filesize from id :%s = %s", sid,filesize);
+ Posix.exit(0);
+ return;
+ }
+ var chksum = this.query("SELECT checksum FROM Attachment WHERE id = %d".printf(
+ int.parse(sid)
+ ));
+ var mime_filename = this.query("SELECT mime_filename FROM Attachment WHERE id = %d".printf(
+ int.parse(sid)));
+
this.query("""
this.query("""
- SELECT
-
- attachment_init(
- msgid,
- checksum,
- mime_filename,
- filesize
- ) as id
- FROM
- attachment
- WHERE
- id = %d
-
+ SELECT
+ attachment_init(
+ '%s', '%s', '%s', %d
+ ) as id
+
""".printf(
""".printf(
- int.parse(sid)
+ this.mysql_escape(this.active_message_exim_id),
+ this.mysql_escape(chksum),
+ this.mysql_escape(mime_filename),
+ int.parse(filesize)
));
this.query("""
));
this.query("""
- SELECT attachment_update(
- %d, -- in_id INT(11),
- '%s', -- in_mime_type varchar(255),
- %d, -- in_mime_size int(11),
- '%s', -- in_created DATETIME,
- '%s' -- in_mailfort_sig varchar(64)
-
- )""
-
-
+ SELECT attachment_update(
+ %d, -- in_id INT(11),
+ '%s', -- in_mime_type varchar(255),
+ '%s', -- in_created DATETIME,
+ '%s' -- in_mailfort_sig varchar(64)
+ )
""".printf(
int.parse(sid),
"", // this will be ignored..
""".printf(
int.parse(sid),
"", // this will be ignored..
- 0, // this will be ingored..
this.created_date,
this.mysql_escape(this.active_message_x_mailfort_sig)
)
);
this.created_date,
this.mysql_escape(this.active_message_x_mailfort_sig)
)
);
-
-
+ this.mysql.store_result();
+
+
}
}
@@
-435,7
+439,7
@@
public class Strip : GLib.Object {
// at this point we have to do our database magic...
//filesize / name / date / checksum / mimetype -- into mailfort should be OK.
// at this point we have to do our database magic...
//filesize / name / date / checksum / mimetype -- into mailfort should be OK.
- this.query("""
+
var file_id =
this.query("""
SELECT
attachment_init(
SELECT
attachment_init(
@@
-451,30
+455,22
@@
public class Strip : GLib.Object {
this.mysql_escape( attachment.get_filename() ), // what is thsi is invalid?
file_size)
);
this.mysql_escape( attachment.get_filename() ), // what is thsi is invalid?
file_size)
);
- var file_id = "0";
- var rs = mysql.use_result();
-
- var row = rs.fetch_row();
-
- var target_fn = "";
-
- //var create_dir = this.created_dir;
-
+
- if (
rs == null || rs.num_rows()
< 1) {
+ if (
file_id.length
< 1) {
GLib.debug("ERROR - CALL to attachment_init failed");
Posix.unlink(fn);
return;
}
GLib.debug("ERROR - CALL to attachment_init failed");
Posix.unlink(fn);
return;
}
- file_id = row[0];
+
if (int.parse(file_id) < 1) {
GLib.debug("ERROR - CALL to attachment_init failed - returned 0?");
Posix.unlink(fn);
return;
}
if (int.parse(file_id) < 1) {
GLib.debug("ERROR - CALL to attachment_init failed - returned 0?");
Posix.unlink(fn);
return;
}
-
+
GLib.debug("fn = %s, m5=%s, id= %s", filename, mime_type, this.active_message_id);
this.query("""
GLib.debug("fn = %s, m5=%s, id= %s", filename, mime_type, this.active_message_id);
this.query("""
@@
-483,7
+479,7
@@
public class Strip : GLib.Object {
%d, -- in_id INT(11),
'%s', -- in_mime_type varchar(255),
'%s', -- in_created DATETIME,
%d, -- in_id INT(11),
'%s', -- in_mime_type varchar(255),
'%s', -- in_created DATETIME,
- '%s'
,
-- in_mailfort_sig varchar(64)
+ '%s' -- in_mailfort_sig varchar(64)
) as result
""".printf(
) as result
""".printf(
@@
-492,12
+488,12
@@
public class Strip : GLib.Object {
this.created_date,
this.mysql_escape(this.active_message_x_mailfort_sig)
));
this.created_date,
this.mysql_escape(this.active_message_x_mailfort_sig)
));
-
+ this.mysql.store_result();
this.used_space_after += file_size;
this.used_space_after += file_size;
-
+ var target_fn = "";
if (StripApplication.opt_is_extracting) {
target_fn = StripApplication.opt_target_path + "/" + this.created_dir +"/"+ file_id + "-" + filename;
if (StripApplication.opt_is_extracting) {
target_fn = StripApplication.opt_target_path + "/" + this.created_dir +"/"+ file_id + "-" + filename;
@@
-516,8
+512,7
@@
public class Strip : GLib.Object {
int.parse(file_id),
this.mysql_escape( stored)
));
int.parse(file_id),
this.mysql_escape( stored)
));
-
-
+
var rep = new GMime.Part.with_type("text","html");
// we have to set up a redirect server - to redirect hpasite... to their internal service..
rep.set_filename(filename);
var rep = new GMime.Part.with_type("text","html");
// we have to set up a redirect server - to redirect hpasite... to their internal service..
rep.set_filename(filename);
@@
-558,12
+553,24
@@
public class Strip : GLib.Object {
}
}
-
- public int query(string str)
+ public string query(string str)
+ {
+ return this.real_query(true, str);
+ }
+ public string execute(string str)
+ {
+ return this.real_query(false, str);
+ }
+ public string real_query(bool need_return, string str)
{
{
+ GLib.debug("Before Query : %u : %s\n", this.mysql.errno(), this.mysql.error());
+
+
if (StripApplication.opt_debug_sql) {
GLib.debug("SQL: %s\n", str);
}
if (StripApplication.opt_debug_sql) {
GLib.debug("SQL: %s\n", str);
}
+
+
var rc= this.mysql.query(str);
if ( rc != 0 ) {
var rc= this.mysql.query(str);
if ( rc != 0 ) {
@@
-571,7
+578,30
@@
public class Strip : GLib.Object {
GLib.debug("ERROR %u: Query failed: %s\n", this.mysql.errno(), this.mysql.error());
Posix.exit(1);
}
GLib.debug("ERROR %u: Query failed: %s\n", this.mysql.errno(), this.mysql.error());
Posix.exit(1);
}
- return rc;
+
+
+ var rs = mysql.use_result();
+
+ var got_row = false;
+ string[] row;
+ string ret = "";
+ while( (row = rs.fetch_row()) != null) {
+ got_row = true;
+ ret = row[0];
+
+ }
+ if (!need_return) {
+ return "";
+ }
+ if (!got_row) {
+ GLib.debug("ERROR : no rows returned");
+ Posix.exit(1);
+ return "";
+ }
+ GLib.debug("got %s", ret);
+ return ret;
+
+
}
public string mysql_escape(string str)
}
public string mysql_escape(string str)