[pmmail-list] time to clear trash - performance

Dave Saville pmmail-list@blueprintsoftwareworks.com
Tue, 16 Oct 2001 10:16:35 +0100 (BST)


OK gang, here is a rexx script to clear trash and update folder.bag &
folder.uct.

It will do all the trash folders it can find. Change the path on the
first SysFileTree to the location of your PMMAIL folders. Note it is
object rexx, not classic, in order to get the Y2K date format.

In pmmail turn off the "Empty trash at shutdown" flag

DO NOT RUN WITH PMMAIL RUNNING

My system went from minutes to under 20 seconds - so what the hell is
pmmail doing?

************************************************************
/* Purpose:  clean pmmail trash folders */
/* Author: D C Saville dave.saville@cwcom.net */
/* Date: October 2001 */

PARSE ARG days

IF days = '' THEN
   days = 7 /* if message is >= days old it will be deleted */

/* find all pmmail account dirs */

CALL SysFileTree 'D:\Apps\SouthSide\PMMail\*.act', 'dirs', 'OD'

xdirs = dirs.0 /* number of account dirs */

now = Date('B') /* todays date */

cwd = Directory() /* save current directory */

DO WHILE xdirs <> 0 /* now loop around trash folders */
   CALL Directory dirs.xdirs'\TRASH.FLD' /* cd to each trash folder
*/
   exists = Stream('FOLDER.BAG', 'C', 'Query Exists')

   IF exists = '' THEN do
      SAY 'FOLDER.BAG does not exist in 'dirs.xdirs
      xdirs = xdirs - 1
      iterate
   END

   update = 0 /* to see if we did anything */
   unread = 0 /* unread count for FOLDER.UCT */

   CALL Stream 'FOLDER1.BAG', 'C', 'Open Write Replace'
   
   DO FOREVER
      stuff = LineIn('FOLDER.BAG')
      
      IF Stream('FOLDER.BAG', 'S') = 'NOTREADY' THEN LEAVE
      
      PARSE VAR stuff col1 'DE'x col2 'DE'x msgdate 'DE'x time 'DE'x
subject 'DE'x add1 'DE'x add2 'DE'x add3 'DE'x from 'DE'x size 'DE'x
file 'DE'x rest 

      diff = now - Date('b', SubStr(msgdate, 1, 4)||SubStr(msgdate,
6, 2)||SubStr(msgdate, 9, 2), 'S')
      
      IF diff >= days THEN DO 
	 CALL SysDestroyObject dirs.xdirs'\TRASH.FLD\'file
	 update = 1 /* show FOLDER.BAG has been changed */
      END 
      ELSE do
	 CALL LineOut 'FOLDER1.BAG', stuff

	 IF SubStr(stuff, 1, 1) = '0' THEN
	    unread = unread + 1
      END 
   END

   CALL Stream 'FOLDER.BAG', 'C', 'CLOSE'
   CALL Stream 'FOLDER1.BAG', 'C', 'CLOSE'
   
   IF update = 1 THEN DO
      CALL SysDestroyObject dirs.xdirs'\TRASH.FLD\FOLDER.BAG'
      '@rename FOLDER1.BAG FOLDER.BAG'
      /* update FOLDER.UCT */
      CALL Stream 'FOLDER.UCT', 'C', 'Open Write Replace'
      CALL CharOut 'FOLDER.UCT', unread
      CALL Stream 'FOLDER.UCT', 'C', 'CLOSE'
   END
   ELSE
      CALL SysDestroyObject dirs.xdirs'\TRASH.FLD\FOLDER1.BAG'

   xdirs = xdirs - 1
END

CALL Directory cwd /* restore calling directory
*/

**********************************************************************
*************
--
Regards

Dave Saville

- pmmail-list - The PMMail Dicussion List ---------------------------
To POST to the list, send your message to:
pmmail-list@blueprintsoftwareworks.com

To UNSUBSCRIBE, send a message to mdaemon@bmtmicro.com with the first 
line of the message body being...
UNSUBSCRIBE pmmail-list@blueprintsoftwareworks.com
---------------------------------------------------------------------