I don't check here if canonicalDir still exists to avoid `stat` call. If removal of canonicalDir fails, it won't change the flow or raise exception because it's `finally` clause. I can put `stat` call if you really want to.