Friday 5 October 2007

Deleting folders in WebDAV

I was coding up support for the DELETE request in WebDAV and came across yet another difference between Windows and OS X. I had a good run of things "just working" on both operating systems, but I guess it had to come to an end eventually.

Let's say I have the following directory:

Images
|_ img1.png
|_ img2.png
|_ img3.png
When you delete the directory in OS X, the following requests are sent:
DELETE Images/img3.png
DELETE Images/img2.png
DELETE Images/img1.png
DELETE Images
When you delete the directory in Windows, the following requests are sent:
DELETE Images

Spot the difference?

I'd rather have a different DELETE request sent for each file and folder, allowing me to delete the temporary files along with the DB entries much more easily. Having said that, I'm not totally against "the Windows way". It is better for performance but it will leave a lot of temp files hanging around because the request would take too long if I went through and deleted each one. That's not really a problem because they will be cleaned up eventually, or reused.

Luckily, OS X sends the requests from the bottom up, allowing me to process both methods in the same way. So on OS X, temp files will be deleted; on Windows, they will not be.

It's not the individual processes that get to me. It's that fact that there are (again) two different ways of doing things.

...and don't get me started on Vista!