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
Timelines: family | ancestors | descendants | both | smtp
Files: files | file ages | folders
SHA3-256: 98400909bca9b7c592e44d44745b263209b9acf3a916c58f5e792f7a670fd21b
User & Date: drh 2018-06-30 20:51:40.165
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
Side-by-Side Diff Ignore Whitespace Patch
Changes to src/smtp.c.
891
892
893
894
895
896
897
898

899
900
901
902
903
904
905
906
907
908



909
910
911
912
913
914
915
891
892
893
894
895
896
897

898
899
900
901
902
903
904
905
906
907

908
909
910
911
912
913
914
915
916
917







-
+









-
+
+
+







   && blob_size(&p->msg)
   && (p->srvrFlags & SMTPSRV_DRYRUN)==0
  ){
    db_begin_transaction();
    if( p->idTranscript==0 ) smtp_server_schema(0);
    db_prepare(&s,
      "INSERT INTO emailblob(ets,etime,etxt)"
      " VALUES(:ets,now(),:etxt)"
      " VALUES(:ets,now(),compress(:etxt))"
    );
    if( !bFinish && p->idTranscript==0 ){
      db_bind_null(&s, ":ets");
      db_bind_null(&s, ":etxt");
      db_step(&s);
      db_reset(&s);
      p->idTranscript = db_last_insert_rowid();
    }else if( bFinish ){
      if( p->idTranscript ){
        db_multi_exec("UPDATE emailblob SET etxt=%Q WHERE emailid=%lld",
        db_multi_exec(
           "UPDATE emailblob SET etxt=compress(%Q)"
           " WHERE emailid=%lld",
           blob_str(&p->transcript), p->idTranscript);
      }else{
        db_bind_null(&s, ":ets");
        db_bind_str(&s, ":etxt", &p->transcript);
        db_step(&s);
        db_reset(&s);
        p->idTranscript = db_last_insert_rowid();
962
963
964
965
966
967
968

969
970
971
972
973
974
975
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978







+







  if( find_option("trace",0,0)!=0 ) x.srvrFlags |= SMTPSRV_STDERR;
  if( find_option("dryrun",0,0)!=0 ) x.srvrFlags |= SMTPSRV_DRYRUN;
  verify_all_options();
  if( g.argc!=3 ) usage("DBNAME");
  zDbName = g.argv[2];
  zDbName = enter_chroot_jail(zDbName, 0);
  db_open_repository(zDbName);
  add_content_sql_commands(g.db);
  smtp_server_send(&x, "220 %s ESMTP https://fossil-scm.org/ %s\r\n",
                   zDomain, MANIFEST_VERSION);
  while( smtp_server_gets(&x, z, sizeof(z)) ){
    if( strncmp(z, "EHLO", 4)==0  && fossil_isspace(z[4]) ){
      smtp_server_send(&x, "250 ok\r\n");
    }else
    if( strncmp(z, "HELO", 4)==0  && fossil_isspace(z[4]) ){
Changes to src/webmail.c.
43
44
45
46
47
48
49

50
51
52
53


54
55
56
57
58
59
60
43
44
45
46
47
48
49
50
51
52
53

54
55
56
57
58
59
60
61
62







+



-
+
+







  }
  if( !db_table_exists("repository","emailbox") ){
    style_header("Webmail Not Available");
    @ <p>This repository is not configured to provide webmail</p>
    style_footer();
    return;
  }
  add_content_sql_commands(g.db);
  emailid = atoi(PD("id","0"));
  if( emailid>0 ){
    blob_init(&sql, 0, 0);
    blob_append_sql(&sql, "SELECT etxt FROM emailblob WHERE emailid=%d",
    blob_append_sql(&sql, "SELECT decompress(etxt)"
                          " FROM emailblob WHERE emailid=%d",
                          emailid);
    if( !g.perm.Admin ){
      blob_append_sql(&sql, " AND EXISTS(SELECT 1 FROM emailbox WHERE"
                            " euser=%Q AND emsgid=emailid)", g.zLogin);
    }
    db_prepare_blob(&q, &sql);
    blob_reset(&sql);