So today bigsight greeted us with the inability to save new profile photos. A quick glance at the logs revealed it was throwing "too many links" errors when trying to save photos. I didn't understand at first, but after poking around in the photos directory I realized that the attachment_fu plugin was saving all of the photos in one directory, and that directory had hit the hard limit for number of entries.
That's not supposed to happen, as attachment_fu uses the 37 Signals method of id partitioning, where files are stored in directory sets based on their ID. Why wasn't attachment_fu doing this like it should? Because it was an ancient version, and I never even noticed because it was always working fine.
Upgrading to the latest version isn't a problem, but how do I get all of the existing files into the scheme that the latest library expects?
Just a few lines of code to run through all of the photos and the magic function extracted from the current version of attachment_fu:
def partitioned_path(id, *args)
("%08d" % id).scan(/..../) + args
end
Of course, it took forever to convert photos in 10 different sizes for 30,000 profiles!