hi

Since TB folks don't seem to care much about this:

https://bugzilla.mozilla.org/show_bug.cgi?id=340265

And, since it's also annoying as hell to watch Trash fill up
and your backend servers running out of juice trying to deal
with 300,000 msgs there, I've come up with a server-side workaround.

I wasn't happy with enabling quota for Trash and messages marked as deleted
since I don't want to punish users for removing junk, and certainly don't want
them to run over their quota and stop getting mail when they are trying to
cleanup.
It's counter-intuitive and counterproductive, especially when it's
not exactly their fault.

I know that Mr Sam prefers client problems to be fixed by their authors, but
the reality is that despite of what we may think about particular
implementations, people are and will be using them, and even if it's fixed
eventually it will take a while for users to upgrade, and it's sysadmins
who will have to deal with performance issues caused by old bugs.

So, whether the following patch is gonna be included into Courier or not,
I'm gonna publish it here for those who have to deal with the issue at hand
and can't wait for TB or whoever to fix this.

The patch below allows you to set a limit on the number of messages users can
move into Trash at a time.
It also allows you to set the maximum number of messages users can put into
their Trash folders via IMAP.
It doesn't prevent direct mail delivery to the Trash folder and doesn't
affect quota calculation in any way.

Compile imap/imapd.c with TB_TRASH_HACK defined to enable it, then set
TB_TRASH_SELECT and TB_TRASH_TOTAL in etc/imapd.
The default is max 500 messages moved to Trash at a time with
maximum 20,000 messages in the folder.
If either is exceeded, it tells user what to do.
The Shift-Del is TB specific, but I haven't seen other clients
causing the problem, so I've customized the error message to target
TB users.


--- imapd.c.orig        Fri Sep 14 23:15:18 2007
+++ imapd.c     Sat Sep 15 03:07:35 2007
@@ -6069,6 +6069,61 @@
                        }
                }

+#ifdef TB_TRASH_HACK
+
+#define TB_TRASH_SELECT_LIMIT 500
+#define TB_TRASH_TOTAL_MSGS 20000
+
+               if (is_reserved(mailbox))
+               {
+                       int counter=0;
+                       int select_limit = TB_TRASH_SELECT_LIMIT;
+                       unsigned long trash_limit = TB_TRASH_TOTAL_MSGS;
+                       char *p;
+
+                       if ( (p = getenv("TB_TRASH_SELECT")) != NULL)
+                       {
+                               select_limit = atoi(p);
+                       }
+                       if ( (p = getenv("TB_TRASH_TOTAL")) != NULL)
+                       {
+                               trash_limit = strtoul(p,NULL,10);
+                       }
+                       if (do_msgset(msgset, &do_count, &counter, uid) ||
+                           counter > select_limit )
+                       {
+                               writes(tag);
+                               writes(" NO [ALERT] Too many messages selected 
to be moved into your Trash folder. Use Shift-Del to skip Trash folder and 
remove them\r\n");
+                               free(msgset);
+                               free(mailbox);
+                               return (0);
+                       }
+                       if (counter > 0)
+                       {
+                          struct imapscaninfo infoptr;
+
+                               imapscan_init(&infoptr);
+                               if (imapscan_maildir(&infoptr, mailbox, 1, 1, 
NULL))
+                               {
+                                       writes(tag);
+                                       writes(" NO [ALERT] COPY to Trash 
failed\r\n");
+                                       free(msgset);
+                                       free(mailbox);
+                                       return (0);
+                               }
+                               if 
(counter+infoptr.nmessages+infoptr.left_unseen > trash_limit)
+                               {
+                                       writes(tag);
+                                       writes(" NO [ALERT] Your Trash folder 
is full. Compact it or/and Use Shift-Del to skip Trash and remove 
messages\r\n");
+                                       imapscan_free(&infoptr);
+                                       free(msgset);
+                                       free(mailbox);
+                                       return (0);
+                               }
+                               imapscan_free(&infoptr);
+                       }
+               }
+#endif /* TB_TRASH_HACK */
                copy_info.mailbox=mailbox;
                copy_info.uidplus_list=NULL;
                copy_info.uidplus_tail= &copy_info.uidplus_list;

-- 
rgds,
serge

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
courier-users mailing list
[email protected]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to