Re: Properties not saved when a script is executed by a Mail rule?
Re: Properties not saved when a script is executed by a Mail rule?
- Subject: Re: Properties not saved when a script is executed by a Mail rule?
- From: Christopher Nebel <email@hidden>
- Date: Wed, 01 Apr 2015 17:05:49 -0700
> On Mar 20, 2015, at 5:52 PM, S. J. Cunningham <email@hidden> wrote:
>
> On Mar 20, 2015, at 7:28 PM, Shane Stanley wrote:
>
>> On 20 Mar 2015, at 9:45 am, Shane Stanley <email@hidden> wrote:
>>>
>>> On 20 Mar 2015, at 7:05 am, S. J. Cunningham <email@hidden> wrote:
>>>>
>>>> The property isn't sticking.
>>>>
>>>> Can someone explain what is going on and how to fix it? Is Mail recompiling the script every time it is called?
>>>
>>> When an application finishes running a script, it's supposed to check whether there have been any changes made, and if so, save the modified version. If that's not happening, possible causes include things like permissions issues, or whoever wrote the application simply didn't implement this step.
>>
>> Now that I think about it more, it sounds like a sandboxing issue. Sandboxed applications can only run scripts stored in a specific folder, and I have a feeling they only have read-access to that folder -- which means they can't write back modified scripts. That doesn't mean the background process that really runs them in such cases can't -- it might be able to -- but it suggests the problem applies across the board to scripts run from sandboxed apps.
>
> I'm using Snow Leopard. I don't think they had implemented sandboxing at that point. Plus the rules allow you to specify a script in any folder, not just Mail's script folder. The script in question is in a development folder I use. When I run the script manually or save it as a script app and run it, it works as expected. It's only when it's called by the Mail rule that it fails.
>
> I also copied it to both BBEdit's Script Folder and Mail's script folder and executed the copy directly from there. Works as expected. It's only when it's executed as a result of a Mail Rule that is fails. Must be a Mail bug. Perhaps it makes a copy of the script each time before executing it. I Binged it but couldn't find anything.
This sounds (and looks, if I’m reading the code correctly) like a bug in Mail, which, slightly counter-intuitively, was fixed by the sandboxing added in Mountain Lion.
Technically, a sandboxed application can run any script it likes, but they will run inside its sandbox, which makes them not very useful, because the default sandbox does not allow sending Apple events. Mountain Lion added a new class, NSUserScriptTask, which allows a sandboxed application to run a script *outside* of its sandbox, but only if the script is in a special folder which the application can read from, but not write to. Despite the script being unwritable by the application, script properties *will* be updated, because NSUserScriptTask takes care of it (outside the sandbox, naturally).
--Chris Nebel
AppleScript Engineering
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden