Check folder exists before attempting to delete it in onBeforeDelete()

Fixes FolderTest.testSetNameChangesFilesystemOnWrite()