Hallo
I have a watch folder action on a raid volume folder. The script is attached via one (of the many) machines which have mounted
the raid volume.
It worked fine for some time but suddenly and without any (at least to our knowledge) reason it stopped working.
My colleague looked at the folder skript and it looked as if it was deactivated (I’m not sure that was true, as it also looked thus today in the morning and when I went to konfiguration and klicked on the folder in the panel it suddenly appeared and after closing the panel (without doing anything) the right click on the folder showed the active script references.
So, my question is:
Am I asking for trouble when attaching a folder watch script to a raid volume via one of several machines connected to it.
The machine where the script is situated is always online and there was no network break up, we know of. As another process
is running on the machine with the script, which is mission critical, we would have known if the machine had been down.
If this is a “possible” scenario, has someone a idea why the script stopped working (and seems to have started working again sometime
after my colleague looked at the folder (but not exactly after, but at least 30 Minutes after).
I’ve seen this on folder actions attached to a NAS drive, which might be the same thing. Essentially, there are times when the folder action seems to be not attached to the folder even when it looks like it is - running “Configure folder actions…” shows that the script is still attached even when it’s not running, and sometimes just running configuration or reattaching the script gets it back to functionality.
I solved this by running an “Initialize Folder Actions” script every morning with cron. Essentially I set properties for all the script files and the folders to which they attach, repeat thru every folder and remove any and all scripts attached, and then attach the script back to it. For this to work, all of my folders that have folder actions are in the FAContainer path, and all the script to attach are in the FAScripts path, and then configScripts is a list of list pairs of each folder name and it’s corresponding script file name.
property FAContainer : "/Volumes/Public/Drop Folder Actions/"
property FAScripts : "/Library/Scripts/Folder Action Scripts/"
property configScripts : {¬
{"Add PDF Proof Watermark", "Acrobat_PDFaddWatermark.scpt"}, ¬
{"DigiType Order", "DigiType_Order.scpt"}, ¬
{"Convert Art to PDF", "Convert_Art_to_PDF.scpt"}, ¬
{"Convert PDF to TIF", "Acrobat_PDF2TIFF.scpt"} ¬
}
repeat with aConfig in configScripts
set theConfig to contents of aConfig
set thisFolderName to item 1 of theConfig
set thisFolder to FAContainer & item 1 of theConfig & "/" as string
set thisFolder to POSIX file thisFolder as alias
set thisScriptName to item 2 of theConfig
set thisScript to FAScripts & item 2 of theConfig as string
set thisScript to POSIX file thisScript as alias
my attachFA(thisFolderName, thisScriptName, thisFolder, thisScript)
end repeat
on attachFA(thisFolderName, thisScriptName, thisFolder, thisScript)
tell application "System Events"
if (exists folder action thisFolderName) then
delete folder action thisFolderName
end if
if not (exists folder action thisFolderName) then
make new folder action ¬
at end of folder actions ¬
with properties {path:(thisFolder as string)}
end if
set thisFAscriptNames to name of every script of folder action thisFolderName
repeat with aScript in thisFAscriptNames
set thisFAscript to contents of aScript
delete script thisFAscript of folder action thisFolderName
end repeat
attach action to thisFolder using thisScript
end tell
end attachFA