Fossil SCM
Store the uncompressed artifact size as an integer field in the emailblob table.
Commit
34b9502698d25a52e9cfee5962f6d4e1b4f5c01edd68b662938da15299dbdd08
Parent
15a533086928eb8…
2 files changed
+9
-4
+5
-2
+9
-4
| --- src/smtp.c | ||
| +++ src/smtp.c | ||
| @@ -641,10 +641,11 @@ | ||
| 641 | 641 | @ CREATE TABLE IF NOT EXISTS repository.emailblob( |
| 642 | 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 | +@ esz INT, -- uncompressed content size | |
| 646 | 647 | @ etxt TEXT -- content of this entry |
| 647 | 648 | @ ); |
| 648 | 649 | @ |
| 649 | 650 | @ -- One row for each mailbox entry. All users emails are stored in |
| 650 | 651 | @ -- this same table. |
| @@ -1069,29 +1070,32 @@ | ||
| 1069 | 1070 | ){ |
| 1070 | 1071 | db_begin_write(); |
| 1071 | 1072 | if( p->idTranscript==0 ) smtp_server_schema(0); |
| 1072 | 1073 | p->nRef = 0; |
| 1073 | 1074 | db_prepare(&s, |
| 1074 | - "INSERT INTO emailblob(ets,etime,etxt,enref)" | |
| 1075 | - " VALUES(:ets,now(),compress(:etxt),0)" | |
| 1075 | + "INSERT INTO emailblob(ets,etime,etxt,enref,esz)" | |
| 1076 | + " VALUES(:ets,now(),compress(:etxt),0,:esz)" | |
| 1076 | 1077 | ); |
| 1077 | 1078 | p->nEts++; |
| 1078 | 1079 | if( !bFinish && p->idTranscript==0 ){ |
| 1079 | 1080 | db_bind_null(&s, ":ets"); |
| 1080 | 1081 | db_bind_null(&s, ":etxt"); |
| 1082 | + db_bind_null(&s, ":esz"); | |
| 1081 | 1083 | db_step(&s); |
| 1082 | 1084 | db_reset(&s); |
| 1083 | 1085 | p->idTranscript = db_last_insert_rowid(); |
| 1084 | 1086 | }else if( bFinish ){ |
| 1085 | 1087 | if( p->idTranscript ){ |
| 1086 | 1088 | db_multi_exec( |
| 1087 | - "UPDATE emailblob SET etxt=compress(%Q), enref=%d" | |
| 1089 | + "UPDATE emailblob SET etxt=compress(%Q), enref=%d, esz=%d" | |
| 1088 | 1090 | " WHERE emailid=%lld", |
| 1089 | - blob_str(&p->transcript), p->nEts, p->idTranscript); | |
| 1091 | + blob_str(&p->transcript), p->nEts, blob_size(&p->transcript), | |
| 1092 | + p->idTranscript); | |
| 1090 | 1093 | }else{ |
| 1091 | 1094 | db_bind_null(&s, ":ets"); |
| 1092 | 1095 | db_bind_str(&s, ":etxt", &p->transcript); |
| 1096 | + db_bind_int(&s, ":esz", blob_size(&p->transcript)); | |
| 1093 | 1097 | db_step(&s); |
| 1094 | 1098 | db_reset(&s); |
| 1095 | 1099 | p->idTranscript = db_last_insert_rowid(); |
| 1096 | 1100 | db_multi_exec( |
| 1097 | 1101 | "UPDATE emailblob SET enref=%d WHERE emailid=%lld", |
| @@ -1100,10 +1104,11 @@ | ||
| 1100 | 1104 | /* smtp_server_send(p, "221-Transcript id %lld nref %d\r\n", |
| 1101 | 1105 | ** p->idTranscript, p->nEts); */ |
| 1102 | 1106 | } |
| 1103 | 1107 | db_bind_int64(&s, ":ets", p->idTranscript); |
| 1104 | 1108 | db_bind_str(&s, ":etxt", &p->msg); |
| 1109 | + db_bind_int(&s, ":esz", blob_size(&p->msg)); | |
| 1105 | 1110 | db_step(&s); |
| 1106 | 1111 | db_finalize(&s); |
| 1107 | 1112 | p->idMsg = db_last_insert_rowid(); |
| 1108 | 1113 | |
| 1109 | 1114 | /* make entries in emailbox and emailoutq */ |
| 1110 | 1115 |
| --- src/smtp.c | |
| +++ src/smtp.c | |
| @@ -641,10 +641,11 @@ | |
| 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 | @ ); |
| 648 | @ |
| 649 | @ -- One row for each mailbox entry. All users emails are stored in |
| 650 | @ -- this same table. |
| @@ -1069,29 +1070,32 @@ | |
| 1069 | ){ |
| 1070 | db_begin_write(); |
| 1071 | if( p->idTranscript==0 ) smtp_server_schema(0); |
| 1072 | p->nRef = 0; |
| 1073 | db_prepare(&s, |
| 1074 | "INSERT INTO emailblob(ets,etime,etxt,enref)" |
| 1075 | " VALUES(:ets,now(),compress(:etxt),0)" |
| 1076 | ); |
| 1077 | p->nEts++; |
| 1078 | if( !bFinish && p->idTranscript==0 ){ |
| 1079 | db_bind_null(&s, ":ets"); |
| 1080 | db_bind_null(&s, ":etxt"); |
| 1081 | db_step(&s); |
| 1082 | db_reset(&s); |
| 1083 | p->idTranscript = db_last_insert_rowid(); |
| 1084 | }else if( bFinish ){ |
| 1085 | if( p->idTranscript ){ |
| 1086 | db_multi_exec( |
| 1087 | "UPDATE emailblob SET etxt=compress(%Q), enref=%d" |
| 1088 | " WHERE emailid=%lld", |
| 1089 | blob_str(&p->transcript), p->nEts, p->idTranscript); |
| 1090 | }else{ |
| 1091 | db_bind_null(&s, ":ets"); |
| 1092 | db_bind_str(&s, ":etxt", &p->transcript); |
| 1093 | db_step(&s); |
| 1094 | db_reset(&s); |
| 1095 | p->idTranscript = db_last_insert_rowid(); |
| 1096 | db_multi_exec( |
| 1097 | "UPDATE emailblob SET enref=%d WHERE emailid=%lld", |
| @@ -1100,10 +1104,11 @@ | |
| 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); |
| 1107 | p->idMsg = db_last_insert_rowid(); |
| 1108 | |
| 1109 | /* make entries in emailbox and emailoutq */ |
| 1110 |
| --- src/smtp.c | |
| +++ src/smtp.c | |
| @@ -641,10 +641,11 @@ | |
| 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 | @ esz INT, -- uncompressed content size |
| 647 | @ etxt TEXT -- content of this entry |
| 648 | @ ); |
| 649 | @ |
| 650 | @ -- One row for each mailbox entry. All users emails are stored in |
| 651 | @ -- this same table. |
| @@ -1069,29 +1070,32 @@ | |
| 1070 | ){ |
| 1071 | db_begin_write(); |
| 1072 | if( p->idTranscript==0 ) smtp_server_schema(0); |
| 1073 | p->nRef = 0; |
| 1074 | db_prepare(&s, |
| 1075 | "INSERT INTO emailblob(ets,etime,etxt,enref,esz)" |
| 1076 | " VALUES(:ets,now(),compress(:etxt),0,:esz)" |
| 1077 | ); |
| 1078 | p->nEts++; |
| 1079 | if( !bFinish && p->idTranscript==0 ){ |
| 1080 | db_bind_null(&s, ":ets"); |
| 1081 | db_bind_null(&s, ":etxt"); |
| 1082 | db_bind_null(&s, ":esz"); |
| 1083 | db_step(&s); |
| 1084 | db_reset(&s); |
| 1085 | p->idTranscript = db_last_insert_rowid(); |
| 1086 | }else if( bFinish ){ |
| 1087 | if( p->idTranscript ){ |
| 1088 | db_multi_exec( |
| 1089 | "UPDATE emailblob SET etxt=compress(%Q), enref=%d, esz=%d" |
| 1090 | " WHERE emailid=%lld", |
| 1091 | blob_str(&p->transcript), p->nEts, blob_size(&p->transcript), |
| 1092 | p->idTranscript); |
| 1093 | }else{ |
| 1094 | db_bind_null(&s, ":ets"); |
| 1095 | db_bind_str(&s, ":etxt", &p->transcript); |
| 1096 | db_bind_int(&s, ":esz", blob_size(&p->transcript)); |
| 1097 | db_step(&s); |
| 1098 | db_reset(&s); |
| 1099 | p->idTranscript = db_last_insert_rowid(); |
| 1100 | db_multi_exec( |
| 1101 | "UPDATE emailblob SET enref=%d WHERE emailid=%lld", |
| @@ -1100,10 +1104,11 @@ | |
| 1104 | /* smtp_server_send(p, "221-Transcript id %lld nref %d\r\n", |
| 1105 | ** p->idTranscript, p->nEts); */ |
| 1106 | } |
| 1107 | db_bind_int64(&s, ":ets", p->idTranscript); |
| 1108 | db_bind_str(&s, ":etxt", &p->msg); |
| 1109 | db_bind_int(&s, ":esz", blob_size(&p->msg)); |
| 1110 | db_step(&s); |
| 1111 | db_finalize(&s); |
| 1112 | p->idMsg = db_last_insert_rowid(); |
| 1113 | |
| 1114 | /* make entries in emailbox and emailoutq */ |
| 1115 |
+5
-2
| --- src/webmail.c | ||
| +++ src/webmail.c | ||
| @@ -819,21 +819,23 @@ | ||
| 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'), esz," | |
| 825 | 825 | " length(etxt)" |
| 826 | 826 | " FROM emailblob ORDER BY etime DESC, emailid DESC"); |
| 827 | 827 | @ <table border="1" cellpadding="5" cellspacing="0"> |
| 828 | - @ <tr><th> emailid <th> enref <th> ets <th> etime <th> size </tr> | |
| 828 | + @ <tr><th> emailid <th> enref <th> ets <th> etime \ | |
| 829 | + @ <th> uncompressed <th> compressed </tr> | |
| 829 | 830 | while( db_step(&q)==SQLITE_ROW ){ |
| 830 | 831 | int id = db_column_int(&q, 0); |
| 831 | 832 | int nref = db_column_int(&q, 1); |
| 832 | 833 | int ets = db_column_int(&q, 2); |
| 833 | 834 | const char *zDate = db_column_text(&q, 3); |
| 834 | 835 | int sz = db_column_int(&q,4); |
| 836 | + int csz = db_column_int(&q,5); | |
| 835 | 837 | @ <tr> |
| 836 | 838 | @ <td align="right"><a href="%R/emailblob?id=%d(id)">%d(id)</a> |
| 837 | 839 | @ <td align="right">%d(nref)</td> |
| 838 | 840 | if( ets>0 ){ |
| 839 | 841 | @ <td align="right">%d(ets)</td> |
| @@ -840,12 +842,13 @@ | ||
| 840 | 842 | }else{ |
| 841 | 843 | @ <td> </td> |
| 842 | 844 | } |
| 843 | 845 | @ <td>%h(zDate)</td> |
| 844 | 846 | @ <td align="right">%,d(sz)</td> |
| 847 | + @ <td align="right">%,d(csz)</td> | |
| 845 | 848 | @ </tr> |
| 846 | 849 | } |
| 847 | 850 | @ </table> |
| 848 | 851 | db_finalize(&q); |
| 849 | 852 | } |
| 850 | 853 | style_footer(); |
| 851 | 854 | } |
| 852 | 855 |
| --- src/webmail.c | |
| +++ src/webmail.c | |
| @@ -819,21 +819,23 @@ | |
| 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,12 +842,13 @@ | |
| 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 |
| --- src/webmail.c | |
| +++ src/webmail.c | |
| @@ -819,21 +819,23 @@ | |
| 819 | @ <pre>%h(zContent)</pre> |
| 820 | } |
| 821 | db_finalize(&q); |
| 822 | }else{ |
| 823 | db_prepare(&q, |
| 824 | "SELECT emailid, enref, ets, datetime(etime,'unixepoch'), esz," |
| 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 \ |
| 829 | @ <th> uncompressed <th> compressed </tr> |
| 830 | while( db_step(&q)==SQLITE_ROW ){ |
| 831 | int id = db_column_int(&q, 0); |
| 832 | int nref = db_column_int(&q, 1); |
| 833 | int ets = db_column_int(&q, 2); |
| 834 | const char *zDate = db_column_text(&q, 3); |
| 835 | int sz = db_column_int(&q,4); |
| 836 | int csz = db_column_int(&q,5); |
| 837 | @ <tr> |
| 838 | @ <td align="right"><a href="%R/emailblob?id=%d(id)">%d(id)</a> |
| 839 | @ <td align="right">%d(nref)</td> |
| 840 | if( ets>0 ){ |
| 841 | @ <td align="right">%d(ets)</td> |
| @@ -840,12 +842,13 @@ | |
| 842 | }else{ |
| 843 | @ <td> </td> |
| 844 | } |
| 845 | @ <td>%h(zDate)</td> |
| 846 | @ <td align="right">%,d(sz)</td> |
| 847 | @ <td align="right">%,d(csz)</td> |
| 848 | @ </tr> |
| 849 | } |
| 850 | @ </table> |
| 851 | db_finalize(&q); |
| 852 | } |
| 853 | style_footer(); |
| 854 | } |
| 855 |