Move source.correct_case out of conditional.

The reasoning was that in the non-new_root case, the destination supplied
by the user would either be the exact path of the new file, or the parent
of the new file. Either way, the casing of source shouldn't matter since
only the file itself is being created with the given casing.

But, I realized, since we are doing makedirs in the event that the whole
path leading up to destination doesn't exist, we should create it with
the correct case according to the source. And that can occur regardless
of new_root.
This commit is contained in:
Ethan Dalool 2020-09-06 09:54:28 -07:00
parent 26eaac7119
commit 7840d53212

View file

@ -387,12 +387,12 @@ def copy_file(
raise ValueError(message) raise ValueError(message)
source = pathclass.Path(source) source = pathclass.Path(source)
source.correct_case()
if not source.is_file: if not source.is_file:
raise SourceNotFile(source) raise SourceNotFile(source)
if destination_new_root is not None: if destination_new_root is not None:
source.correct_case()
destination = new_root(source, destination_new_root) destination = new_root(source, destination_new_root)
destination = pathclass.Path(destination) destination = pathclass.Path(destination)