[client] Fix bugs of empty directory handling.