Fun with Mac OS X, Finder and Joomla!
Written by Sam Moffatt   
Monday, 12 January 2009 06:12

After some posts on the Joomla! forum about issues with Joomla! upgrades, I wrote the following in a reply to a post. I'm now putting it here so that I can refer to it at a later date. This covers Mac OS X's Finder and how it behaves when you are copying folders.

Mac OS X's Finder is rather unfriendly with copying. If you are using Finder, it will delete any of the old structure and replace it with the new structure from the source. The dialog it pops up with actually tells you this though you may not realise what it is actually saying or the full implications of what its saying. The text for reference is "An older item named 'joomla' already exists in this location. Do you want to replace it with the newer one you are moving?" The key here is its asking you to replace the older files with the ones in the patch file which results in everything being deleted. The "moving" bit isn't a typo either, copying in Mac OS X only refers to what happens to the original folder, either it gets deleted or it gets left alone (a move is a copy operation followed by a delete in most cases). At this point I would be looking for the back up you made before you upgraded (or your last scheduled back up run).

As a thought experiment, so say I have a folder called "pies" that has three subdirectories called "meat", "apple" and "blueberry" and then I copy another "pies" folder over the top of it with "meat", "apple" and "stargazer" - the old files and the 'blueberry' folder will be wiped out - deleted and replaced with the newer version. This is what has happened here. One potential reason for this is that due to the way the Apple treat applications (they're actually folders), "merge" copying would be undesirable as old application files would be retained resulting in bloat for each upgrade.

For Mac OS X, I prefer to use the command line approach as it tends not to nuke files as much. If you copy the zip file to the Joomla! install directory. Then open up the Terminal (Applications -> Utilities -> Terminal) and do the following:

cd /path/to/joomla

Obviously the /path/to/joomla is specific and the will be the name of the patch file. One thing Apple does do reasonably is copying and pasting with their Terminal app. So what you can do is type "cd " (the space is important), go to Finder and copy the folder that your Joomla! instance is in (you'll need to be in the parent folder to do this) and drag it onto the Terminal window. Don't be worried when it has a little copy icon, its just going to paste the full path of the folder. Once its done that (it'll have something like /Users/username/Site/joomla/ pasted there now) hit enter and then type in "unzip " (the space again is important) and you can then do the same trick you did with the folder with the package. In this case it doesn't actually matter where the package is, it will use an absolute path but it would be easier to put the package file in the same directory that you're going to extract into. As with any process you should always back up before you begin and you should also test the process out in a non-production environment or a replica environment to assure yourself that everything will run properly.