Fix a bug with Client#ensureDirectory