diff -urN courier-imap-1.4.5.20020509/imap/fetch.c courier-imap-1.4.5.20020509-quota/imap/fetch.c
--- courier-imap-1.4.5.20020509/imap/fetch.c	Tue Oct  2 01:05:50 2001
+++ courier-imap-1.4.5.20020509-quota/imap/fetch.c	Mon May 20 09:16:52 2002
@@ -154,8 +154,6 @@
 char    *p, *q, *r;
 int	rc=0;
 struct	imapflags old_flags;
-struct	stat	stat_buf;
-char	quotabuf[QUOTABUFSIZE];
 
 	get_message_flags(mi, 0, &old_flags);
 	p=malloc(strlen(mi->filename)+20);
@@ -172,44 +170,8 @@
 	strcat(strcat(strcpy(r, current_mailbox), "/cur/"), p);
 	if (strcmp(q, r))
 	{
-		if (!is_trash(current_mailbox)	/* Changes in TRASH take no
-						** effect.
-						*/
-			&& old_flags.deleted != flags->deleted
-			&& maildir_getquota(current_mailbox, quotabuf) == 0
-			&& fstat(fd, &stat_buf) == 0)
-		{
-		long	nbytes;
-		unsigned long unbytes;
-		int	nmsgs=1;
-		int	quotafd;
-
-			if (maildir_parsequota(mi->filename, &unbytes) == 0)
-				nbytes=unbytes;
-			else
-				nbytes=stat_buf.st_size;
-			if ( flags->deleted )
-			{
-				nbytes= -nbytes;
-				nmsgs= -nmsgs;
-			}
-			if ( maildir_checkquota(current_mailbox, &quotafd,
-				quotabuf, nbytes, nmsgs) && errno != EAGAIN &&
-				nbytes >= 0)
-			{
-				if (quotafd >= 0)	close(quotafd);
-				rc= -1;
-			}
-			else
-			{
-				maildir_addquota(current_mailbox, quotafd,
-					quotabuf, nbytes, nmsgs);
-				if (quotafd >= 0)	close(quotafd);
-			}
-		}
-
-		if (rc == 0)
-			rename(q, r);
+	  rc = 0;
+	  rename(q, r);
 	}
 	free(q);
 	free(r);
diff -urN courier-imap-1.4.5.20020509/imap/imapd.c courier-imap-1.4.5.20020509-quota/imap/imapd.c
--- courier-imap-1.4.5.20020509/imap/imapd.c	Wed Apr 17 20:16:11 2002
+++ courier-imap-1.4.5.20020509-quota/imap/imapd.c	Mon May 20 09:16:52 2002
@@ -736,7 +736,7 @@
 	}
 #endif
 #endif
-	if (!is_trash(mailbox) && maildir_getquota(mailbox, quotabuf) == 0)
+	if (maildir_getquota(mailbox, quotabuf) == 0)
 	{
 	int	quotafd;
 
@@ -1098,6 +1098,7 @@
 struct imapflags flags;
 char	*old_name;
 int	move_to_trash=0;
+char	quotabuf[QUOTABUFSIZE];
 
 	fetch_free_cache();
 
@@ -1107,6 +1108,13 @@
 
 	for (j=0; j < current_mailbox_info.nmessages; j++)
 	{
+	  
+	  long	nbytes= 0;
+	  unsigned long unbytes;
+	  int	nmsgs=1;
+	  int	quotafd;
+		    
+
 		get_message_flags(current_mailbox_info.msgs+j, 0, &flags);
 
 		if (!flags.deleted)
@@ -1114,6 +1122,25 @@
 
 		old_name=alloc_filename(current_mailbox,
 			current_mailbox_info.msgs[j].filename);
+
+
+		maildir_getquota(current_mailbox, quotabuf);
+		
+		if (maildir_parsequota(old_name,&unbytes) == 0 )
+		  nbytes=unbytes;
+		
+		nbytes= -nbytes;
+		nmsgs= -nmsgs;
+		
+		if ( maildir_checkquota(current_mailbox, &quotafd, quotabuf, nbytes, nmsgs) && errno != EAGAIN && nbytes >= 0)
+		  {
+		    if (quotafd >= 0)       close(quotafd);
+		  }
+		else
+		  {
+		    maildir_addquota(current_mailbox, quotafd, quotabuf, nbytes, nmsgs);
+		    if (quotafd >= 0)       close(quotafd);
+		  }
 
 		if (is_sharedsubdir(current_mailbox))
 		{
diff -urN courier-imap-1.4.5.20020509/imap/storeinfo.c courier-imap-1.4.5.20020509-quota/imap/storeinfo.c
--- courier-imap-1.4.5.20020509/imap/storeinfo.c	Wed Nov 14 05:14:24 2001
+++ courier-imap-1.4.5.20020509-quota/imap/storeinfo.c	Mon May 20 09:16:52 2002
@@ -268,8 +268,6 @@
 int	fd;
 
 	--n;
-	if (is_trash(info->destmailbox))
-		return (0);	/* No problems dumping everything into trash */
 
 	fd=imapscan_openfile(current_mailbox, &current_mailbox_info, n);
 	if (fd < 0)	return (0);
diff -urN courier-imap-1.4.5.20020509/maildir/maildirquota.c courier-imap-1.4.5.20020509-quota/maildir/maildirquota.c
--- courier-imap-1.4.5.20020509/maildir/maildirquota.c	Sat May  4 04:16:34 2002
+++ courier-imap-1.4.5.20020509-quota/maildir/maildirquota.c	Mon May 20 09:28:34 2002
@@ -568,7 +568,7 @@
 int	n;
 
 	if ( *subdir != '.' || strcmp(subdir, ".") == 0 ||
-		strcmp(subdir, "..") == 0 || strcmp(subdir, "." TRASH) == 0)
+		strcmp(subdir, "..") == 0)
 		return (0);
 
 	p=(char *)malloc(strlen(dir)+strlen(subdir)+2);
@@ -606,7 +606,7 @@
 int	n;
 
 	if ( *subdir != '.' || strcmp(subdir, ".") == 0 ||
-		strcmp(subdir, "..") == 0 || strcmp(subdir, "." TRASH) == 0)
+		strcmp(subdir, "..") == 0)
 		return (0);
 
 	p=(char *)malloc(strlen(dir)+strlen(subdir)+2);
@@ -644,12 +644,10 @@
 			n += 3;
 			while (*n >= 'A' && *n <= 'Z')
 			{
-				if (*n == 'T')	break;
 				++n;
 			}
 			break;
 		}
-		if (*n == 'T')	continue;
 		n=de->d_name;
 
 
