Fossil SCM
The emailblob table holds content a little while before deleting it. Change the /test-emailblob page to /emailblob, though it is still only accessible by the administrator.
Commit
15a533086928eb88a3448390e752e0588346cde2caaee8ae39abb08eda07a567
Parent
f880aa82aad218a…
2 files changed
+25
-8
+15
-8
+25
-8
| --- src/smtp.c | ||
| +++ src/smtp.c | ||
| @@ -637,11 +637,11 @@ | ||
| 637 | 637 | */ |
| 638 | 638 | static const char zEmailSchema[] = |
| 639 | 639 | @ -- bulk storage is in a separate table. This table can store either |
| 640 | 640 | @ -- the body of email messages or transcripts of smtp sessions. |
| 641 | 641 | @ CREATE TABLE IF NOT EXISTS repository.emailblob( |
| 642 | -@ emailid INTEGER PRIMARY KEY, -- numeric idea for the entry | |
| 642 | +@ emailid INTEGER PRIMARY KEY AUTOINCREMENT, -- numeric idea for the entry | |
| 643 | 643 | @ enref INT, -- Number of references to this blob |
| 644 | 644 | @ ets INT, -- Corresponding transcript, or NULL |
| 645 | 645 | @ etime INT, -- insertion time, secs since 1970 |
| 646 | 646 | @ etxt TEXT -- content of this entry |
| 647 | 647 | @ ); |
| @@ -680,23 +680,24 @@ | ||
| 680 | 680 | @ -- Triggers to automatically keep the emailblob.enref field up to date |
| 681 | 681 | @ -- as entries in the emailblob, emailbox, and emailoutq tables are |
| 682 | 682 | @ -- deleted. |
| 683 | 683 | @ CREATE TRIGGER IF NOT EXISTS repository.emailblob_d1 |
| 684 | 684 | @ AFTER DELETE ON emailblob BEGIN |
| 685 | -@ DELETE FROM emailblob WHERE enref<=1 AND emailid=old.ets; | |
| 686 | 685 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid=old.ets; |
| 687 | 686 | @ END; |
| 688 | 687 | @ CREATE TRIGGER IF NOT EXISTS repository.emailbox_d1 |
| 689 | 688 | @ AFTER DELETE ON emailbox BEGIN |
| 690 | -@ DELETE FROM emailblob WHERE enref<=1 AND emailid=old.emsgid; | |
| 691 | 689 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid=old.emsgid; |
| 692 | 690 | @ END; |
| 693 | 691 | @ CREATE TRIGGER IF NOT EXISTS repository.emailoutq_d1 |
| 694 | 692 | @ AFTER DELETE ON emailoutq BEGIN |
| 695 | -@ DELETE FROM emailblob WHERE enref<=1 AND emailid IN (old.ets,old.emsgid); | |
| 696 | 693 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid IN (old.ets,old.emsgid); |
| 697 | 694 | @ END; |
| 695 | +@ | |
| 696 | +@ -- An index on the emailblob entries which are unreferenced. | |
| 697 | +@ CREATE INDEX IF NOT EXISTS repository.emailblob_nref ON emailblob(enref) | |
| 698 | +@ WHERE enref<=0; | |
| 698 | 699 | ; |
| 699 | 700 | |
| 700 | 701 | /* |
| 701 | 702 | ** Code used to delete the email tables. |
| 702 | 703 | */ |
| @@ -1058,10 +1059,11 @@ | ||
| 1058 | 1059 | ** Add this email to the database. |
| 1059 | 1060 | */ |
| 1060 | 1061 | static void smtp_server_route_incoming(SmtpServer *p, int bFinish){ |
| 1061 | 1062 | Stmt s; |
| 1062 | 1063 | int i; |
| 1064 | + int nEtsStart = p->nEts; | |
| 1063 | 1065 | if( p->zFrom |
| 1064 | 1066 | && p->nTo |
| 1065 | 1067 | && blob_size(&p->msg) |
| 1066 | 1068 | && (p->srvrFlags & SMTPSRV_DRYRUN)==0 |
| 1067 | 1069 | ){ |
| @@ -1093,12 +1095,12 @@ | ||
| 1093 | 1095 | p->idTranscript = db_last_insert_rowid(); |
| 1094 | 1096 | db_multi_exec( |
| 1095 | 1097 | "UPDATE emailblob SET enref=%d WHERE emailid=%lld", |
| 1096 | 1098 | p->nEts, p->idTranscript); |
| 1097 | 1099 | } |
| 1098 | - smtp_server_send(p, "221-Transcript id %lld nref %d\r\n", | |
| 1099 | - p->idTranscript, p->nEts); | |
| 1100 | + /* smtp_server_send(p, "221-Transcript id %lld nref %d\r\n", | |
| 1101 | + ** p->idTranscript, p->nEts); */ | |
| 1100 | 1102 | } |
| 1101 | 1103 | db_bind_int64(&s, ":ets", p->idTranscript); |
| 1102 | 1104 | db_bind_str(&s, ":etxt", &p->msg); |
| 1103 | 1105 | db_step(&s); |
| 1104 | 1106 | db_finalize(&s); |
| @@ -1119,10 +1121,16 @@ | ||
| 1119 | 1121 | ); |
| 1120 | 1122 | }else{ |
| 1121 | 1123 | db_multi_exec( |
| 1122 | 1124 | "DELETE FROM emailblob WHERE emailid=%lld", p->idMsg |
| 1123 | 1125 | ); |
| 1126 | + p->nEts = nEtsStart; | |
| 1127 | + } | |
| 1128 | + | |
| 1129 | + /* Clean out legacy entries */ | |
| 1130 | + if( bFinish ){ | |
| 1131 | + db_multi_exec("DELETE FROM emailblob WHERE enref<=0"); | |
| 1124 | 1132 | } |
| 1125 | 1133 | |
| 1126 | 1134 | /* Finish the transaction after all changes are implemented */ |
| 1127 | 1135 | db_commit_transaction(); |
| 1128 | 1136 | } |
| @@ -1130,26 +1138,29 @@ | ||
| 1130 | 1138 | } |
| 1131 | 1139 | |
| 1132 | 1140 | /* |
| 1133 | 1141 | ** COMMAND: test-emailblob-refcheck |
| 1134 | 1142 | ** |
| 1135 | -** Usage: %fossil test-emailblob-refcheck [--repair] [--full] | |
| 1143 | +** Usage: %fossil test-emailblob-refcheck [--repair] [--full] [--clean] | |
| 1136 | 1144 | ** |
| 1137 | 1145 | ** Verify that the emailblob.enref field is correct. Report any errors. |
| 1138 | 1146 | ** Use the --repair command to fix up the enref field. The --full option |
| 1139 | 1147 | ** gives a full report showing the enref value on all entries in the |
| 1140 | -** emailblob table. | |
| 1148 | +** emailblob table. If the --clean flags is used together with --repair, | |
| 1149 | +** then emailblob table entires with enref==0 are removed. | |
| 1141 | 1150 | */ |
| 1142 | 1151 | void test_refcheck_emailblob(void){ |
| 1143 | 1152 | int doRepair; |
| 1144 | 1153 | int fullReport; |
| 1154 | + int doClean; | |
| 1145 | 1155 | Blob sql; |
| 1146 | 1156 | Stmt q; |
| 1147 | 1157 | int nErr = 0; |
| 1148 | 1158 | db_find_and_open_repository(0, 0); |
| 1149 | 1159 | fullReport = find_option("full",0,0)!=0; |
| 1150 | 1160 | doRepair = find_option("repair",0,0)!=0; |
| 1161 | + doClean = find_option("clean",0,0)!=0; | |
| 1151 | 1162 | verify_all_options(); |
| 1152 | 1163 | if( !db_table_exists("repository","emailblob") ){ |
| 1153 | 1164 | fossil_print("emailblob table is not configured - nothing to check\n"); |
| 1154 | 1165 | return; |
| 1155 | 1166 | } |
| @@ -1166,10 +1177,16 @@ | ||
| 1166 | 1177 | ); |
| 1167 | 1178 | if( doRepair ){ |
| 1168 | 1179 | db_multi_exec( |
| 1169 | 1180 | "UPDATE emailblob SET enref=(SELECT n FROM refcnt WHERE id=emailid)" |
| 1170 | 1181 | ); |
| 1182 | + if( doClean ){ | |
| 1183 | + db_multi_exec( | |
| 1184 | + "UPDATE emailblob SET ets=NULL WHERE enref<=0;" | |
| 1185 | + "DELETE FROM emailblob WHERE enref<=0;" | |
| 1186 | + ); | |
| 1187 | + } | |
| 1171 | 1188 | } |
| 1172 | 1189 | blob_init(&sql, 0, 0); |
| 1173 | 1190 | blob_append_sql(&sql, |
| 1174 | 1191 | "SELECT a.emailid, a.enref, b.n" |
| 1175 | 1192 | " FROM emailblob AS a JOIN refcnt AS b ON a.emailid=b.id" |
| 1176 | 1193 |
| --- src/smtp.c | |
| +++ src/smtp.c | |
| @@ -637,11 +637,11 @@ | |
| 637 | */ |
| 638 | static const char zEmailSchema[] = |
| 639 | @ -- bulk storage is in a separate table. This table can store either |
| 640 | @ -- the body of email messages or transcripts of smtp sessions. |
| 641 | @ CREATE TABLE IF NOT EXISTS repository.emailblob( |
| 642 | @ emailid INTEGER PRIMARY KEY, -- numeric idea for the entry |
| 643 | @ enref INT, -- Number of references to this blob |
| 644 | @ ets INT, -- Corresponding transcript, or NULL |
| 645 | @ etime INT, -- insertion time, secs since 1970 |
| 646 | @ etxt TEXT -- content of this entry |
| 647 | @ ); |
| @@ -680,23 +680,24 @@ | |
| 680 | @ -- Triggers to automatically keep the emailblob.enref field up to date |
| 681 | @ -- as entries in the emailblob, emailbox, and emailoutq tables are |
| 682 | @ -- deleted. |
| 683 | @ CREATE TRIGGER IF NOT EXISTS repository.emailblob_d1 |
| 684 | @ AFTER DELETE ON emailblob BEGIN |
| 685 | @ DELETE FROM emailblob WHERE enref<=1 AND emailid=old.ets; |
| 686 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid=old.ets; |
| 687 | @ END; |
| 688 | @ CREATE TRIGGER IF NOT EXISTS repository.emailbox_d1 |
| 689 | @ AFTER DELETE ON emailbox BEGIN |
| 690 | @ DELETE FROM emailblob WHERE enref<=1 AND emailid=old.emsgid; |
| 691 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid=old.emsgid; |
| 692 | @ END; |
| 693 | @ CREATE TRIGGER IF NOT EXISTS repository.emailoutq_d1 |
| 694 | @ AFTER DELETE ON emailoutq BEGIN |
| 695 | @ DELETE FROM emailblob WHERE enref<=1 AND emailid IN (old.ets,old.emsgid); |
| 696 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid IN (old.ets,old.emsgid); |
| 697 | @ END; |
| 698 | ; |
| 699 | |
| 700 | /* |
| 701 | ** Code used to delete the email tables. |
| 702 | */ |
| @@ -1058,10 +1059,11 @@ | |
| 1058 | ** Add this email to the database. |
| 1059 | */ |
| 1060 | static void smtp_server_route_incoming(SmtpServer *p, int bFinish){ |
| 1061 | Stmt s; |
| 1062 | int i; |
| 1063 | if( p->zFrom |
| 1064 | && p->nTo |
| 1065 | && blob_size(&p->msg) |
| 1066 | && (p->srvrFlags & SMTPSRV_DRYRUN)==0 |
| 1067 | ){ |
| @@ -1093,12 +1095,12 @@ | |
| 1093 | p->idTranscript = db_last_insert_rowid(); |
| 1094 | db_multi_exec( |
| 1095 | "UPDATE emailblob SET enref=%d WHERE emailid=%lld", |
| 1096 | p->nEts, p->idTranscript); |
| 1097 | } |
| 1098 | smtp_server_send(p, "221-Transcript id %lld nref %d\r\n", |
| 1099 | p->idTranscript, p->nEts); |
| 1100 | } |
| 1101 | db_bind_int64(&s, ":ets", p->idTranscript); |
| 1102 | db_bind_str(&s, ":etxt", &p->msg); |
| 1103 | db_step(&s); |
| 1104 | db_finalize(&s); |
| @@ -1119,10 +1121,16 @@ | |
| 1119 | ); |
| 1120 | }else{ |
| 1121 | db_multi_exec( |
| 1122 | "DELETE FROM emailblob WHERE emailid=%lld", p->idMsg |
| 1123 | ); |
| 1124 | } |
| 1125 | |
| 1126 | /* Finish the transaction after all changes are implemented */ |
| 1127 | db_commit_transaction(); |
| 1128 | } |
| @@ -1130,26 +1138,29 @@ | |
| 1130 | } |
| 1131 | |
| 1132 | /* |
| 1133 | ** COMMAND: test-emailblob-refcheck |
| 1134 | ** |
| 1135 | ** Usage: %fossil test-emailblob-refcheck [--repair] [--full] |
| 1136 | ** |
| 1137 | ** Verify that the emailblob.enref field is correct. Report any errors. |
| 1138 | ** Use the --repair command to fix up the enref field. The --full option |
| 1139 | ** gives a full report showing the enref value on all entries in the |
| 1140 | ** emailblob table. |
| 1141 | */ |
| 1142 | void test_refcheck_emailblob(void){ |
| 1143 | int doRepair; |
| 1144 | int fullReport; |
| 1145 | Blob sql; |
| 1146 | Stmt q; |
| 1147 | int nErr = 0; |
| 1148 | db_find_and_open_repository(0, 0); |
| 1149 | fullReport = find_option("full",0,0)!=0; |
| 1150 | doRepair = find_option("repair",0,0)!=0; |
| 1151 | verify_all_options(); |
| 1152 | if( !db_table_exists("repository","emailblob") ){ |
| 1153 | fossil_print("emailblob table is not configured - nothing to check\n"); |
| 1154 | return; |
| 1155 | } |
| @@ -1166,10 +1177,16 @@ | |
| 1166 | ); |
| 1167 | if( doRepair ){ |
| 1168 | db_multi_exec( |
| 1169 | "UPDATE emailblob SET enref=(SELECT n FROM refcnt WHERE id=emailid)" |
| 1170 | ); |
| 1171 | } |
| 1172 | blob_init(&sql, 0, 0); |
| 1173 | blob_append_sql(&sql, |
| 1174 | "SELECT a.emailid, a.enref, b.n" |
| 1175 | " FROM emailblob AS a JOIN refcnt AS b ON a.emailid=b.id" |
| 1176 |
| --- src/smtp.c | |
| +++ src/smtp.c | |
| @@ -637,11 +637,11 @@ | |
| 637 | */ |
| 638 | static const char zEmailSchema[] = |
| 639 | @ -- bulk storage is in a separate table. This table can store either |
| 640 | @ -- the body of email messages or transcripts of smtp sessions. |
| 641 | @ CREATE TABLE IF NOT EXISTS repository.emailblob( |
| 642 | @ emailid INTEGER PRIMARY KEY AUTOINCREMENT, -- numeric idea for the entry |
| 643 | @ enref INT, -- Number of references to this blob |
| 644 | @ ets INT, -- Corresponding transcript, or NULL |
| 645 | @ etime INT, -- insertion time, secs since 1970 |
| 646 | @ etxt TEXT -- content of this entry |
| 647 | @ ); |
| @@ -680,23 +680,24 @@ | |
| 680 | @ -- Triggers to automatically keep the emailblob.enref field up to date |
| 681 | @ -- as entries in the emailblob, emailbox, and emailoutq tables are |
| 682 | @ -- deleted. |
| 683 | @ CREATE TRIGGER IF NOT EXISTS repository.emailblob_d1 |
| 684 | @ AFTER DELETE ON emailblob BEGIN |
| 685 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid=old.ets; |
| 686 | @ END; |
| 687 | @ CREATE TRIGGER IF NOT EXISTS repository.emailbox_d1 |
| 688 | @ AFTER DELETE ON emailbox BEGIN |
| 689 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid=old.emsgid; |
| 690 | @ END; |
| 691 | @ CREATE TRIGGER IF NOT EXISTS repository.emailoutq_d1 |
| 692 | @ AFTER DELETE ON emailoutq BEGIN |
| 693 | @ UPDATE emailblob SET enref=enref-1 WHERE emailid IN (old.ets,old.emsgid); |
| 694 | @ END; |
| 695 | @ |
| 696 | @ -- An index on the emailblob entries which are unreferenced. |
| 697 | @ CREATE INDEX IF NOT EXISTS repository.emailblob_nref ON emailblob(enref) |
| 698 | @ WHERE enref<=0; |
| 699 | ; |
| 700 | |
| 701 | /* |
| 702 | ** Code used to delete the email tables. |
| 703 | */ |
| @@ -1058,10 +1059,11 @@ | |
| 1059 | ** Add this email to the database. |
| 1060 | */ |
| 1061 | static void smtp_server_route_incoming(SmtpServer *p, int bFinish){ |
| 1062 | Stmt s; |
| 1063 | int i; |
| 1064 | int nEtsStart = p->nEts; |
| 1065 | if( p->zFrom |
| 1066 | && p->nTo |
| 1067 | && blob_size(&p->msg) |
| 1068 | && (p->srvrFlags & SMTPSRV_DRYRUN)==0 |
| 1069 | ){ |
| @@ -1093,12 +1095,12 @@ | |
| 1095 | p->idTranscript = db_last_insert_rowid(); |
| 1096 | db_multi_exec( |
| 1097 | "UPDATE emailblob SET enref=%d WHERE emailid=%lld", |
| 1098 | p->nEts, p->idTranscript); |
| 1099 | } |
| 1100 | /* smtp_server_send(p, "221-Transcript id %lld nref %d\r\n", |
| 1101 | ** p->idTranscript, p->nEts); */ |
| 1102 | } |
| 1103 | db_bind_int64(&s, ":ets", p->idTranscript); |
| 1104 | db_bind_str(&s, ":etxt", &p->msg); |
| 1105 | db_step(&s); |
| 1106 | db_finalize(&s); |
| @@ -1119,10 +1121,16 @@ | |
| 1121 | ); |
| 1122 | }else{ |
| 1123 | db_multi_exec( |
| 1124 | "DELETE FROM emailblob WHERE emailid=%lld", p->idMsg |
| 1125 | ); |
| 1126 | p->nEts = nEtsStart; |
| 1127 | } |
| 1128 | |
| 1129 | /* Clean out legacy entries */ |
| 1130 | if( bFinish ){ |
| 1131 | db_multi_exec("DELETE FROM emailblob WHERE enref<=0"); |
| 1132 | } |
| 1133 | |
| 1134 | /* Finish the transaction after all changes are implemented */ |
| 1135 | db_commit_transaction(); |
| 1136 | } |
| @@ -1130,26 +1138,29 @@ | |
| 1138 | } |
| 1139 | |
| 1140 | /* |
| 1141 | ** COMMAND: test-emailblob-refcheck |
| 1142 | ** |
| 1143 | ** Usage: %fossil test-emailblob-refcheck [--repair] [--full] [--clean] |
| 1144 | ** |
| 1145 | ** Verify that the emailblob.enref field is correct. Report any errors. |
| 1146 | ** Use the --repair command to fix up the enref field. The --full option |
| 1147 | ** gives a full report showing the enref value on all entries in the |
| 1148 | ** emailblob table. If the --clean flags is used together with --repair, |
| 1149 | ** then emailblob table entires with enref==0 are removed. |
| 1150 | */ |
| 1151 | void test_refcheck_emailblob(void){ |
| 1152 | int doRepair; |
| 1153 | int fullReport; |
| 1154 | int doClean; |
| 1155 | Blob sql; |
| 1156 | Stmt q; |
| 1157 | int nErr = 0; |
| 1158 | db_find_and_open_repository(0, 0); |
| 1159 | fullReport = find_option("full",0,0)!=0; |
| 1160 | doRepair = find_option("repair",0,0)!=0; |
| 1161 | doClean = find_option("clean",0,0)!=0; |
| 1162 | verify_all_options(); |
| 1163 | if( !db_table_exists("repository","emailblob") ){ |
| 1164 | fossil_print("emailblob table is not configured - nothing to check\n"); |
| 1165 | return; |
| 1166 | } |
| @@ -1166,10 +1177,16 @@ | |
| 1177 | ); |
| 1178 | if( doRepair ){ |
| 1179 | db_multi_exec( |
| 1180 | "UPDATE emailblob SET enref=(SELECT n FROM refcnt WHERE id=emailid)" |
| 1181 | ); |
| 1182 | if( doClean ){ |
| 1183 | db_multi_exec( |
| 1184 | "UPDATE emailblob SET ets=NULL WHERE enref<=0;" |
| 1185 | "DELETE FROM emailblob WHERE enref<=0;" |
| 1186 | ); |
| 1187 | } |
| 1188 | } |
| 1189 | blob_init(&sql, 0, 0); |
| 1190 | blob_append_sql(&sql, |
| 1191 | "SELECT a.emailid, a.enref, b.n" |
| 1192 | " FROM emailblob AS a JOIN refcnt AS b ON a.emailid=b.id" |
| 1193 |
+15
-8
| --- src/webmail.c | ||
| +++ src/webmail.c | ||
| @@ -759,11 +759,11 @@ | ||
| 759 | 759 | @ </script> |
| 760 | 760 | db_end_transaction(0); |
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | /* |
| 764 | -** WEBPAGE: test-emailblob | |
| 764 | +** WEBPAGE: emailblob | |
| 765 | 765 | ** |
| 766 | 766 | ** This page, accessible only to administrators, allows easy viewing of |
| 767 | 767 | ** the emailblob table - the table that contains the text of email messages |
| 768 | 768 | ** both inbound and outbound, and transcripts of SMTP sessions. |
| 769 | 769 | ** |
| @@ -779,16 +779,16 @@ | ||
| 779 | 779 | return; |
| 780 | 780 | } |
| 781 | 781 | add_content_sql_commands(g.db); |
| 782 | 782 | style_header("emailblob table"); |
| 783 | 783 | if( id>0 ){ |
| 784 | - style_submenu_element("Index", "%R/test-emailblob"); | |
| 784 | + style_submenu_element("Index", "%R/emailblob"); | |
| 785 | 785 | @ <ul> |
| 786 | 786 | db_prepare(&q, "SELECT emailid FROM emailblob WHERE ets=%d", id); |
| 787 | 787 | while( db_step(&q)==SQLITE_ROW ){ |
| 788 | 788 | int id = db_column_int(&q, 0); |
| 789 | - @ <li> <a href="%R/test-emailblob?id=%d(id)">emailblob entry %d(id)</a> | |
| 789 | + @ <li> <a href="%R/emailblob?id=%d(id)">emailblob entry %d(id)</a> | |
| 790 | 790 | } |
| 791 | 791 | db_finalize(&q); |
| 792 | 792 | db_prepare(&q, "SELECT euser, estate FROM emailbox WHERE emsgid=%d", id); |
| 793 | 793 | while( db_step(&q)==SQLITE_ROW ){ |
| 794 | 794 | const char *zUser = db_column_text(&q, 0); |
| @@ -819,26 +819,33 @@ | ||
| 819 | 819 | @ <pre>%h(zContent)</pre> |
| 820 | 820 | } |
| 821 | 821 | db_finalize(&q); |
| 822 | 822 | }else{ |
| 823 | 823 | db_prepare(&q, |
| 824 | - "SELECT emailid, enref, ets, datetime(etime,'unixepoch')" | |
| 824 | + "SELECT emailid, enref, ets, datetime(etime,'unixepoch')," | |
| 825 | + " length(etxt)" | |
| 825 | 826 | " FROM emailblob ORDER BY etime DESC, emailid DESC"); |
| 826 | 827 | @ <table border="1" cellpadding="5" cellspacing="0"> |
| 827 | - @ <tr><th> emailid <th> enref <th> ets <th> etime</tr> | |
| 828 | + @ <tr><th> emailid <th> enref <th> ets <th> etime <th> size </tr> | |
| 828 | 829 | while( db_step(&q)==SQLITE_ROW ){ |
| 829 | 830 | int id = db_column_int(&q, 0); |
| 830 | 831 | int nref = db_column_int(&q, 1); |
| 831 | 832 | int ets = db_column_int(&q, 2); |
| 832 | 833 | const char *zDate = db_column_text(&q, 3); |
| 834 | + int sz = db_column_int(&q,4); | |
| 833 | 835 | @ <tr> |
| 834 | - @ <td><a href="%R/test-emailblob?id=%d(id)">%d(id)</a> | |
| 835 | - @ <td>%d(nref)</td> | |
| 836 | - @ <td>%d(ets)</td> | |
| 836 | + @ <td align="right"><a href="%R/emailblob?id=%d(id)">%d(id)</a> | |
| 837 | + @ <td align="right">%d(nref)</td> | |
| 838 | + if( ets>0 ){ | |
| 839 | + @ <td align="right">%d(ets)</td> | |
| 840 | + }else{ | |
| 841 | + @ <td> </td> | |
| 842 | + } | |
| 837 | 843 | @ <td>%h(zDate)</td> |
| 844 | + @ <td align="right">%,d(sz)</td> | |
| 838 | 845 | @ </tr> |
| 839 | 846 | } |
| 840 | 847 | @ </table> |
| 841 | 848 | db_finalize(&q); |
| 842 | 849 | } |
| 843 | 850 | style_footer(); |
| 844 | 851 | } |
| 845 | 852 |
| --- src/webmail.c | |
| +++ src/webmail.c | |
| @@ -759,11 +759,11 @@ | |
| 759 | @ </script> |
| 760 | db_end_transaction(0); |
| 761 | } |
| 762 | |
| 763 | /* |
| 764 | ** WEBPAGE: test-emailblob |
| 765 | ** |
| 766 | ** This page, accessible only to administrators, allows easy viewing of |
| 767 | ** the emailblob table - the table that contains the text of email messages |
| 768 | ** both inbound and outbound, and transcripts of SMTP sessions. |
| 769 | ** |
| @@ -779,16 +779,16 @@ | |
| 779 | return; |
| 780 | } |
| 781 | add_content_sql_commands(g.db); |
| 782 | style_header("emailblob table"); |
| 783 | if( id>0 ){ |
| 784 | style_submenu_element("Index", "%R/test-emailblob"); |
| 785 | @ <ul> |
| 786 | db_prepare(&q, "SELECT emailid FROM emailblob WHERE ets=%d", id); |
| 787 | while( db_step(&q)==SQLITE_ROW ){ |
| 788 | int id = db_column_int(&q, 0); |
| 789 | @ <li> <a href="%R/test-emailblob?id=%d(id)">emailblob entry %d(id)</a> |
| 790 | } |
| 791 | db_finalize(&q); |
| 792 | db_prepare(&q, "SELECT euser, estate FROM emailbox WHERE emsgid=%d", id); |
| 793 | while( db_step(&q)==SQLITE_ROW ){ |
| 794 | const char *zUser = db_column_text(&q, 0); |
| @@ -819,26 +819,33 @@ | |
| 819 | @ <pre>%h(zContent)</pre> |
| 820 | } |
| 821 | db_finalize(&q); |
| 822 | }else{ |
| 823 | db_prepare(&q, |
| 824 | "SELECT emailid, enref, ets, datetime(etime,'unixepoch')" |
| 825 | " FROM emailblob ORDER BY etime DESC, emailid DESC"); |
| 826 | @ <table border="1" cellpadding="5" cellspacing="0"> |
| 827 | @ <tr><th> emailid <th> enref <th> ets <th> etime</tr> |
| 828 | while( db_step(&q)==SQLITE_ROW ){ |
| 829 | int id = db_column_int(&q, 0); |
| 830 | int nref = db_column_int(&q, 1); |
| 831 | int ets = db_column_int(&q, 2); |
| 832 | const char *zDate = db_column_text(&q, 3); |
| 833 | @ <tr> |
| 834 | @ <td><a href="%R/test-emailblob?id=%d(id)">%d(id)</a> |
| 835 | @ <td>%d(nref)</td> |
| 836 | @ <td>%d(ets)</td> |
| 837 | @ <td>%h(zDate)</td> |
| 838 | @ </tr> |
| 839 | } |
| 840 | @ </table> |
| 841 | db_finalize(&q); |
| 842 | } |
| 843 | style_footer(); |
| 844 | } |
| 845 |
| --- src/webmail.c | |
| +++ src/webmail.c | |
| @@ -759,11 +759,11 @@ | |
| 759 | @ </script> |
| 760 | db_end_transaction(0); |
| 761 | } |
| 762 | |
| 763 | /* |
| 764 | ** WEBPAGE: emailblob |
| 765 | ** |
| 766 | ** This page, accessible only to administrators, allows easy viewing of |
| 767 | ** the emailblob table - the table that contains the text of email messages |
| 768 | ** both inbound and outbound, and transcripts of SMTP sessions. |
| 769 | ** |
| @@ -779,16 +779,16 @@ | |
| 779 | return; |
| 780 | } |
| 781 | add_content_sql_commands(g.db); |
| 782 | style_header("emailblob table"); |
| 783 | if( id>0 ){ |
| 784 | style_submenu_element("Index", "%R/emailblob"); |
| 785 | @ <ul> |
| 786 | db_prepare(&q, "SELECT emailid FROM emailblob WHERE ets=%d", id); |
| 787 | while( db_step(&q)==SQLITE_ROW ){ |
| 788 | int id = db_column_int(&q, 0); |
| 789 | @ <li> <a href="%R/emailblob?id=%d(id)">emailblob entry %d(id)</a> |
| 790 | } |
| 791 | db_finalize(&q); |
| 792 | db_prepare(&q, "SELECT euser, estate FROM emailbox WHERE emsgid=%d", id); |
| 793 | while( db_step(&q)==SQLITE_ROW ){ |
| 794 | const char *zUser = db_column_text(&q, 0); |
| @@ -819,26 +819,33 @@ | |
| 819 | @ <pre>%h(zContent)</pre> |
| 820 | } |
| 821 | db_finalize(&q); |
| 822 | }else{ |
| 823 | db_prepare(&q, |
| 824 | "SELECT emailid, enref, ets, datetime(etime,'unixepoch')," |
| 825 | " length(etxt)" |
| 826 | " FROM emailblob ORDER BY etime DESC, emailid DESC"); |
| 827 | @ <table border="1" cellpadding="5" cellspacing="0"> |
| 828 | @ <tr><th> emailid <th> enref <th> ets <th> etime <th> size </tr> |
| 829 | while( db_step(&q)==SQLITE_ROW ){ |
| 830 | int id = db_column_int(&q, 0); |
| 831 | int nref = db_column_int(&q, 1); |
| 832 | int ets = db_column_int(&q, 2); |
| 833 | const char *zDate = db_column_text(&q, 3); |
| 834 | int sz = db_column_int(&q,4); |
| 835 | @ <tr> |
| 836 | @ <td align="right"><a href="%R/emailblob?id=%d(id)">%d(id)</a> |
| 837 | @ <td align="right">%d(nref)</td> |
| 838 | if( ets>0 ){ |
| 839 | @ <td align="right">%d(ets)</td> |
| 840 | }else{ |
| 841 | @ <td> </td> |
| 842 | } |
| 843 | @ <td>%h(zDate)</td> |
| 844 | @ <td align="right">%,d(sz)</td> |
| 845 | @ </tr> |
| 846 | } |
| 847 | @ </table> |
| 848 | db_finalize(&q); |
| 849 | } |
| 850 | style_footer(); |
| 851 | } |
| 852 |