Fix a bug occurs in the process of checing if existing target directory is empty.