Why knowing developers is good for you

Today I realized that a bunch of the photos in my Gallery 2 was missing. To be more precise, the full size image was missing but all the derivatives (thumbnails and resizes) were displaying just fine. Since I normally don't browse my own Gallery viewing the original full size images this problem had not caught my attention until one of my users informed me of it. I promptly enabled debug mode, and discovered that Gallery was complaining that it could not find the original file on my filesystem. Upon further digging, I discovered that for some reason filename case had not been retained when I moved the g2data folder from my old server to the new one, converting them all to lower case. And, to make things even worse, it had not done this for all files, just some of them. Why this case-conversion happened while I was manually copying the files between the servers I have no idea. It certainly wasn't the fault of Gallery 2, it expects filenames to be consistent and not change around behind it's back. My initial thought was to dig up HDD from my old server and re-transfer the files, but that would have taken considerable time as my g2data directory is about 15GB big. Trying to manually identify which photos were affected by this would be a horrendously tedious task too, but I needed to find a way to deal with it somehow. Thankfully Bharat came to the rescue. After I explained the problem to him, he whipped up a 80 line PHP script that walked through my entire Gallery 2 database, comparing filenames in the database with filenames on the filesystem and identifying the ones that had a lowercase version present. Then the script would spit out a complete list of the whole mv command that had to be executed to fix the problem at hand. The script came up with a list of 880 images that had to be renamed, which would have taken me hours trying to figure out manually. All I had to do was to copy the output of the script into a bash script and execute it, and hey presto, problem solved. This is a perfect example that knowing developers is good for you. I urge you all to go and hug your favorite developer today. They are definately worth it.

Posted by Christian Mohn aka h0bbel

Post metadata


Published January 24, 2007 21:51
0 comments

Tagged with , , , and 


0 Responses to Why knowing developers is good for you:

  • There are currently no comments.

0 Pingbacks to Why knowing developers is good for you:

  • There are currently no pingbacks.

Leave a Reply


Contact me

Lets talk!
Get in touch