Fix a handling dir/bucket bug