Commit 0ca68be4 0ca68be4402b6d4ea11f49667f236483a6ad26ee by Sergey Poznyakoff

(mda_catch_body): Check if the message is to be delivered here, instead

of doing it in deliver(). If the message was modified, drop it to the
separate temporary file first, so that all modifications get to the user's
maildrop.
1 parent 5c6aee36
...@@ -74,6 +74,9 @@ SCM ...@@ -74,6 +74,9 @@ SCM
74 mda_catch_body (void *data, mailbox_t mbox) 74 mda_catch_body (void *data, mailbox_t mbox)
75 { 75 {
76 struct mda_data *md = data; 76 struct mda_data *md = data;
77 message_t mesg = NULL;
78 attribute_t attr = NULL;
79 FILE *fp = md->fp;
77 80
78 if (access (md->progfile, R_OK)) 81 if (access (md->progfile, R_OK))
79 { 82 {
...@@ -82,7 +85,34 @@ mda_catch_body (void *data, mailbox_t mbox) ...@@ -82,7 +85,34 @@ mda_catch_body (void *data, mailbox_t mbox)
82 } 85 }
83 else 86 else
84 scm_primitive_load (scm_makfrom0str (md->progfile)); 87 scm_primitive_load (scm_makfrom0str (md->progfile));
85 mda (md->fp, md->argv[0], mbox); 88
89 mailbox_get_message (mbox, 1, &mesg);
90 message_get_attribute (mesg, &attr);
91 if (attribute_is_deleted (attr))
92 return SCM_BOOL_F;
93
94 if (message_is_modified (mesg))
95 {
96 char *tname;
97 int fd = mu_tempfile (NULL, &tname);
98 mailbox_t tmp;
99
100 close (fd);
101 if (mailbox_create (&tmp, tname) == 0
102 && mailbox_open (tmp, MU_STREAM_RDWR) == 0)
103 {
104 mailbox_append_message (tmp, mesg);
105 mailbox_close (tmp);
106 mailbox_destroy (&tmp);
107
108 fp = fopen (tname, "r");
109 }
110 unlink (tname);
111 }
112
113 mda (fp, md->argv[0]);
114 if (fp != md->fp)
115 fclose (fp);
86 return SCM_BOOL_F; 116 return SCM_BOOL_F;
87 } 117 }
88 118
......