Don't attempt to unlink a file if it's a directory.
When clearing a gallery folder, handle it in a recursive manner.