Skip to content
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

Merged
merged 4 commits into from
Aug 6, 2014

Conversation

kyleknap
Copy link
Contributor

@kyleknap kyleknap commented Aug 5, 2014

Fixes issue: #843

@kyleknap
Copy link
Contributor Author

kyleknap commented Aug 5, 2014

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

@danielgtaylor
Copy link
Contributor

@kyleknap overall this looks like it will solve the issue, but I'm concerned about creating all the new copies of lists with replace_all() - what about something more along the lines of this:

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.

@kyleknap
Copy link
Contributor Author

kyleknap commented Aug 5, 2014

Oh, I did not know about that. It makes sense though. Definitely simplifies the code. I will probably remove replace_all() and wrap that line with normalize_sort() and make sure that it works.

@kyleknap
Copy link
Contributor Author

kyleknap commented Aug 5, 2014

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):
Copy link
Member

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?

Copy link
Contributor Author

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.

@danielgtaylor
Copy link
Contributor

LGTM 🚢-it!

@jamesls
Copy link
Member

jamesls commented Aug 6, 2014

:shipit:

kyleknap added a commit that referenced this pull request Aug 6, 2014
Fix resyncing unnecessarily on windows machines.
@kyleknap kyleknap merged commit c2ce480 into aws:develop Aug 6, 2014
@kyleknap kyleknap deleted the resync_bug branch August 6, 2014 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants