Fossil

Check-in [98400909]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Compress content in the emailblob table.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | smtp
Files: files | file ages | folders
SHA3-256: 98400909bca9b7c592e44d44745b263209b9acf3a916c58f5e792f7a670fd21b
User & Date: drh 2018-06-30 20:51:40
Context
2018-07-11
15:02
Merge changes from trunk. check-in: cde5b96d user: drh tags: smtp
2018-06-30
20:51
Compress content in the emailblob table. check-in: 98400909 user: drh tags: smtp
20:38
First code for the /webmail page. Barely functional. check-in: 8dc832e6 user: drh tags: smtp
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/smtp.c.

   891    891      && blob_size(&p->msg)
   892    892      && (p->srvrFlags & SMTPSRV_DRYRUN)==0
   893    893     ){
   894    894       db_begin_transaction();
   895    895       if( p->idTranscript==0 ) smtp_server_schema(0);
   896    896       db_prepare(&s,
   897    897         "INSERT INTO emailblob(ets,etime,etxt)"
   898         -      " VALUES(:ets,now(),:etxt)"
          898  +      " VALUES(:ets,now(),compress(:etxt))"
   899    899       );
   900    900       if( !bFinish && p->idTranscript==0 ){
   901    901         db_bind_null(&s, ":ets");
   902    902         db_bind_null(&s, ":etxt");
   903    903         db_step(&s);
   904    904         db_reset(&s);
   905    905         p->idTranscript = db_last_insert_rowid();
   906    906       }else if( bFinish ){
   907    907         if( p->idTranscript ){
   908         -        db_multi_exec("UPDATE emailblob SET etxt=%Q WHERE emailid=%lld",
          908  +        db_multi_exec(
          909  +           "UPDATE emailblob SET etxt=compress(%Q)"
          910  +           " WHERE emailid=%lld",
   909    911              blob_str(&p->transcript), p->idTranscript);
   910    912         }else{
   911    913           db_bind_null(&s, ":ets");
   912    914           db_bind_str(&s, ":etxt", &p->transcript);
   913    915           db_step(&s);
   914    916           db_reset(&s);
   915    917           p->idTranscript = db_last_insert_rowid();
................................................................................
   962    964     if( find_option("trace",0,0)!=0 ) x.srvrFlags |= SMTPSRV_STDERR;
   963    965     if( find_option("dryrun",0,0)!=0 ) x.srvrFlags |= SMTPSRV_DRYRUN;
   964    966     verify_all_options();
   965    967     if( g.argc!=3 ) usage("DBNAME");
   966    968     zDbName = g.argv[2];
   967    969     zDbName = enter_chroot_jail(zDbName, 0);
   968    970     db_open_repository(zDbName);
          971  +  add_content_sql_commands(g.db);
   969    972     smtp_server_send(&x, "220 %s ESMTP https://fossil-scm.org/ %s\r\n",
   970    973                      zDomain, MANIFEST_VERSION);
   971    974     while( smtp_server_gets(&x, z, sizeof(z)) ){
   972    975       if( strncmp(z, "EHLO", 4)==0  && fossil_isspace(z[4]) ){
   973    976         smtp_server_send(&x, "250 ok\r\n");
   974    977       }else
   975    978       if( strncmp(z, "HELO", 4)==0  && fossil_isspace(z[4]) ){

Changes to src/webmail.c.

    43     43     }
    44     44     if( !db_table_exists("repository","emailbox") ){
    45     45       style_header("Webmail Not Available");
    46     46       @ <p>This repository is not configured to provide webmail</p>
    47     47       style_footer();
    48     48       return;
    49     49     }
           50  +  add_content_sql_commands(g.db);
    50     51     emailid = atoi(PD("id","0"));
    51     52     if( emailid>0 ){
    52     53       blob_init(&sql, 0, 0);
    53         -    blob_append_sql(&sql, "SELECT etxt FROM emailblob WHERE emailid=%d",
           54  +    blob_append_sql(&sql, "SELECT decompress(etxt)"
           55  +                          " FROM emailblob WHERE emailid=%d",
    54     56                             emailid);
    55     57       if( !g.perm.Admin ){
    56     58         blob_append_sql(&sql, " AND EXISTS(SELECT 1 FROM emailbox WHERE"
    57     59                               " euser=%Q AND emsgid=emailid)", g.zLogin);
    58     60       }
    59     61       db_prepare_blob(&q, &sql);
    60     62       blob_reset(&sql);