[tpop3d-discuss][PATCH]: delete maildirsize file if it exists; be nicer for Maildir++ folders
Arkadiusz Miskiewicz
arekm at pld-linux.org
Fri, 9 Dec 2005 10:03:25 +0100
Hi,
Currently tpop3d isn't capable of working with Maildir++
folders.
Each application accessing Maildir++ folder is supposed to update
maildir/maildirsize file after changing Maildir++ contents. The problem
is that tpop3d isn't doing that and we end up with maildirsize containing
data about already deleted messages (which fools quota calculation
in maildir++ capable software).
The attached patch makes tpop3d usefull in such cases by just
removing maildirsize file when there were some deletions of messages.
The other Maildir++ capable software accessing maildir will just recreate
maildirsize file.=20
Please apply, it's agains cvs version from about month ago.
diff -ur tpop3d-1.5.3.org/maildir.c tpop3d-1.5.3/maildir.c
=2D-- tpop3d-1.5.3.org/maildir.c 2005-12-09 11:07:44.370963000 +0100
+++ tpop3d-1.5.3/maildir.c 2005-12-09 11:16:45.570963000 +0100
@@ -502,10 +502,14 @@
* Apply deletions to a maildir. */
int maildir_apply_changes(mailbox M) {
struct indexpoint *m;
+ struct stat st;
+ char *maildirsizefile;
+ int maildirsizefile_update =3D 0;
if (!M) return 1;
=20
for (m =3D M->index; m < M->index + M->num; ++m) {
if (m->deleted) {
+ maildirsizefile_update++;
if (unlink(m->filename) =3D=3D -1)
log_print(LOG_ERR, "maildir_apply_changes: unlink(%s): %m"=
, m->filename);
/* Warn but proceed anyway. */
@@ -521,6 +525,16 @@
}
}
=20
+ if (maildirsizefile_update) {
+ /* we don't recreate maildirsize file; we delete it and depend on rec=
reation
+ * by MTA or other software accessing mailbox */
+ maildirsizefile =3D xmalloc(strlen(M->name) + strlen("/maildirsize") =
+ 1);
+ sprintf(maildirsizefile, "%s/maildirsize", M->name);
+ if (stat(maildirsizefile, &st) =3D=3D 0 && S_ISREG(st.st_mode))
+ unlink(maildirsizefile);
+ xfree(maildirsizefile);
+ }
+
return 1;
}
=20
=2D-=20
Arkadiusz Mi=B6kiewicz PLD/Linux Team
http://www.t17.ds.pwr.wroc.pl/~misiek/ http://ftp.pld-linux.org/