Re: degrading script performance in Mail
Re: degrading script performance in Mail
- Subject: Re: degrading script performance in Mail
- From: patrick machielse <email@hidden>
- Date: Sun, 28 Aug 2005 20:51:10 +0200
Op 28-aug-2005, om 17:50 heeft deivy petrescu het volgende geschreven:
On Aug 27, 2005, at 15:36, patrick machielse wrote:
What I notice is that the
Mail application gets in a 'comatose' state for longer and longer
after setting the read status of messages. The more I run my
script, the longer it takes Mail to reflect the changes in the
interface. Also there is a lot of spotlight indexing going on, and
the numbers to the right of the mailbox names that indicate the
number of unread messages are not correct. (all of which doesn't
take place when I set the read status by hand in Mail)
do you mind sharing the script?
It is weird, from what I understand, that first run is fine, the
script ended and you are doing something else, then you run it (the
script) again, then the Mail responds differently.
OK. The objective of my code is to mark messages in a mail folder,
and all its sub-folders, unread. My first attempt was:
on setReadStatus(aMailbox, status)
tell application "Mail"
-- go into any nested mailboxes
repeat with box in mailboxes of aMailbox as list
my setReadStatus(box, status)
end repeat
-- process messages in the current mailbox
set the read status of every message in aMailbox to status
end tell
end setReadStatus
The effect of this was that the read status of the messages gets set,
but the numbers indicating the # of unread messages in a mailbox are
wrong, most of the time. I have to click on a mailbox to let Mail
update. Also, if I run my script a few times, (the rest of the script
is innocent...) Mail needs longer and longer to 'post-process'.
After your initial comments I thought: "let's get all messages first,
and then set the read status of all of them in 1 loop:
on getMessagesInBox(aMailbox)
tell application "Mail"
set aList to {}
-- go into nested mailboxes
repeat with box in (mailboxes of aMailbox as list)
set aList to aList & my getMessagesInBox(box)
end repeat
-- add messagges from current mailbox
return aList & (messages of aMailbox as list)
end tell
end getMessagesInBox
on setReadStatus(aMailboxName, status)
tell application "Mail"
set box to mailbox aMailboxName
repeat with msg in my getMessagesInBox(box)
set the read status of msg to status
end repeat
end tell
end setReadStatus
This fixed the number indicators in Mail, but the 'post processing
coma' in Mail still occurs.
patrick
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden