Jump to page content

Bug of the moment 2007-01-17

When I transfer new content to my site, I have to do it in the right order, so that pages don’t get posted before images they contain, and the lowest level in the hierarchy goes up first to minimise the amount of broken links that will occur. There is no race condition protection on a hand-built site!

During yesterday’s update process, I checked up on a folder to see which files I had posted so far (I’d lost track); for some reason, none of them had been uploaded. Knowing that some of them were up, I looked over the folder listing carefully but no, the files were not there. More precisely, all files posted so far this year were missing.

This made no sense. Further inspection revealed the files to exist, but all of them had 2006 for a year instead of 2007. For example, yesterday’s Character Map screenshots:

The screenshots from the preceding update, about FTP authentication:

Note that the dates of the files are correct (16th and 12th January respectively); only the years are wrong. For a while, I believed that the hosting server was screwed up, but before I filed a support ticket, I verified that my About page still showed my age as 26, which told me that the server was fine.

So, what was the FTP server telling me? Here’s a transcript from the server:

Notice that there are no years shown for any files. The server – governed by standard ls behaviour – is not showing any years. Files with no year where the date is equal to or less than now, are from this year. Files with no year whose date puts them in the future, are considered to be from the year before. The first file – dated January 16th – is freshly created whereas the October files date back to last year.

I realised that the bug was in my client software as soon as I saw this:

Despite the top file being new, Fetch 3.0.3 lists all files as being 2006 regardless. So why does Fetch adamantly believe that it’s 2006? Look at the yellow highlight in the transcript: Fetch is quite aware that it is 2007. So what went wrong?

The answer is elementary, dear reader. My Macintosh was last booted in 2006:

When Fetch sees a directory entry with no year, it must substitute in an appropriate year. As far as I can tell, this is a static value chosen at launch time, and re-used until the program closes. Of course, most people do not have their Macintosh on – with Fetch running – over New Year’s, but Fetch is launched at boot on my Mac and never closed. So Fetch wrote down that is is 2006, and never thought to check if the year had changed. I am not sure on which side of the 80-20 rule this case falls, but little things like this do happen! Caching the year is not sensible.

So what of the folder where all files were shown in 2006? Instead of using purely the day and month to determine if a file with no year is plausibly from this year, Fetch appears to add the year first and then check, causing the file to be from the preceding year under all circumstances. That is, for “Jan 16 14:16”, assume 2006-01-16 and compare with today’s date. I can only imagine that this comparison is done via an uncached value of the current date.

I have no absolute proof of what Fetch is up to – maybe there is a more logical explanation that I am missing – but as soon as I restarted Fetch and refreshed the directory listing, Fetch started showing correct years.

Posted 17th January 2007 – Comments and questions?