Let me describe what’s happening. My application watches a hot folder, for folders of files dropped in. When a new folder is detected, the app moves the folder to a folder where it’s working from, a “working folder” for just this application. I have copies of this app running on multiple computers- they all watch the same “hot folder” and have their own uniquely named working folder. The working folder is so they don’t cross-process. The system works well…
Except, sometimes one computer will want to move a folder, and another machine is trying to move the same folder to its working folder at the same time. The Finder gets an error and then displays a dialog asking for an administrator password because it believes the folder is locked/protected. In reality its not, but computer #2 was too slow to grab it. So my app is locked up, the Finder is displaying a password box, and there is a small dialog that shows an unending progress bar trying to move the file, which will increase to several copies of the same move operation if I let the app go for a while.
I’ve got a try block in there which I thought would take care of things, but apparently it does not.
I’d like to know if anyone has a way to streamline this and to make sure that the Finder doesn’t get hung up on files that go missing/moved just milliseconds before it tries to get it.
Here’s the code of the section handles the file moving:
tell application "Finder" update (folder myWatchedFolder) update folder (myWatchedFolderParent & "Output:") try move every item of myWorkingFolder to folder (myWatchedFolderParent & "Error:") end try end tell try tell application "Finder" --LETS PICK THE OLDEST MOD DATE FOLDER, SO FIRST IN FIRST OUT set sortedFiles to every item of folder myWatchedFolder set sortedFiles to (sort sortedFiles by modification date) move last item of sortedFiles to myWorkingFolder set myIDFilesFolder to first folder of myWorkingFolder if (name of myIDFilesFolder) contains " " or (character 6 of (get name of myIDFilesFolder) is not "_") or (character 10 of (get name of myIDFilesFolder) is not "_") or ((count of characters of (get name of myIDFilesFolder)) â‰ 12) then move every item of myWorkingFolder to folder (myWatchedFolderParent & "Error:") set myContinue to false end if end tell on error set myContinue to false end try