Saturday, March 9, 2013

Automation is Automation

The first rule of any technology used in a business is that automation applied to an efficient operation will magnify the efficiency. The second is that automation applied to an inefficient operation will magnify the inefficiency. - Bill Gates

I've got all of my music and movies and TV shows out on a shared drive on my Drobo. I've got this great script I wrote a little bit ago that scans across those drives and automatically adds it into iTunes on the home server. So the theory is that I can run Handbrake on my DVD on any machine, drop the MP4s onto the shared drive, and viola - they appear in iTunes. This command is the magic:

osascript -e "tell application \"iTunes\" to add POSIX file \"${VID_FILEPATH}\""

We're struggling with home Internet again, because this is my life, and AT&T came by to check things out. Whenever AT&T comes back I revert my home network into a standard configuration. Normally I have the AT&T supplied device just bridging the connection over to my much better AirPort Extreme. The challenge is that the AT&T response to this is, "Oh, you're running a non-standard configuration. Obviously the fact that our PPPoE server is dropping your connection is caused by this! It has nothing to do with our servers."

How are these two things related?

iTunes does some sort of magic where it checks if it has already added the file, but it is not doing this through a POSIX path, it is instead doing this through HFS+ magical references that I don't understand. Here is what I do understand: when the AFP mount goes away (because I switched my network back to standard mode) and then comes back, even though the POSIX filepath doesn't change, the HFS+ reference does. And iTunes re-adds.

Switching my home network back to standard mode on Friday was the first time my server had lost connection with Drobo since I started running the script months ago. I have good uptime! Once I switched the network back to normal and ChaosServer reconnected to Drobo - 100% of my content duplicated.

So I solved it by having it add all the POSIX paths to a text file and then checking the text file before loading it. Not the most elegant thing, but it's working.