These callbacks lets you inspect the anticipated copy operation before
it actually occurs. My particular motivation for adding this was to
search for source files which have been renamed, so I can rename the
matching destination file before it attempts to make a duplicate.
With the addition of the BAIL sentinel, you could also use this to
dynamically decide which dirs to skip, if the exclude_ sets are not
good enough for you.
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.
If you have a path that you expect to expect to be a file, it is
confusing to see the traceback where it attempts to listdir because
self.is_file failed and the else was to treat it as a dir.
I prefer this explicit exists check, and explicit dir check.
Yeah, potential for race conditions exists.
I was hesitant at first because of course it can be slow to run,
but previously you'd have to have an if so that you know whether you've
got int or none corresponding to files and folders anyway, so I don't
think the caller-side complexity is increased at all, and saves me from
having to write this as a helper function outside the class.
Only for special cases like preparing to handle permissionerror
would you need to use your own function.
Originally the long name was to make it super clear that by
starting the queue you are going to lose whatever is in pool.jobs.
But then _jobs became private so the end user shouldn't be
touching that anyway. So we're free to make the public interface
simpler and just call it start.