-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix resyncing unnecessarily on windows machines. #865
Conversation
The bug was that windows path uses a back slash as opposed to a forward slash in the path. So, sorting on windows machines would differ from s3 order because of the back slashes. The fix was to replace all operating system separators with forward slashes before the sort and then add them back after the sort. @jamesls @danielgtaylor |
@kyleknap overall this looks like it will solve the issue, but I'm concerned about creating all the new copies of lists with names.sort(key=lambda item: item.replace(os.sep, '/')) Does that make sense? It will sort the list in-place and only temporarily create new strings as keys when comparing items. |
Oh, I did not know about that. It makes sense though. Definitely simplifies the code. I will probably remove |
I just made changes to simplify the code a bit. |
@@ -231,6 +231,16 @@ def relative_path(filename, start=os.path.curdir): | |||
return os.path.abspath(filename) | |||
|
|||
|
|||
def normalize_sort(names, os_sep, character): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any other code that would benefit from this being extracted out into this utils class? It seems very specific to the filegenerator class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No other classes or functions use it. Before the refactoring, there were two larger helper functions. Therefore, it made a little more sense at the time, but now it is just a single line of code. I will change it.
LGTM 🚢-it! |
Fix resyncing unnecessarily on windows machines.
Fixes issue: #843