-
Notifications
You must be signed in to change notification settings - Fork 309
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
Code cleanups and simplifications. #446
Conversation
3e3b200
to
ca7413a
Compare
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.
CI fails. Please look into that.
ca7413a
to
719e41c
Compare
@balamurugana CI failure is fixed. It was some kind of intermittent problem in the CI, and not in the change itself. Got fixed after a force push. |
👍 |
Two comments.. |
719e41c
to
996c813
Compare
No it should not. The I tried to find if there are any bug reports related to Windows and closing files and the with statement, but I didn't see any. If there was such a bug, it would be quite serious and there would be multiple reports.
In the case of In In other situations it is ok for us to encode str type to utf-8 and convert to bytes, as in the library, we know what data we are encoding in all other situations. |
996c813
to
d1e5db2
Compare
Added a comment explaining why we accept only strict bytes in |
policy[1] + '","' + policy[2] + '"]') | ||
policies = self.policies | ||
if self._content_length_range: | ||
policies.append(['content-length-range'] + |
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.
Why not do this inside set_content_length_range()
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.
We probably could do this (and also the expiration time change/comment), but I prefer to do these changes in another refactor - the reason is that I am not sure the current PostPolicy API is cleanly done.
The current implementation has all its methods names like set_expires
, set_key_startswith
, etc but the name set_*
implies that if we do the operation repeatedly, only the last value/call has effect - but the implementation does not satisfy this natural expectation - if we call set_bucket_name
twice, it will append two conditions to the policy, possibly rendering it invalid - in the S3 spec, it seems these policy conditions are conjunctive (AND-ed together). However, the expiration condition, and the content length condition are ok to be set repeatedly to different values, and the programmer's intention is satisfied by the library implementation. I want to make this behaviour consistent in a (near) future refactor.
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.
The current implementation has all its methods names like set_expires, set_key_startswith, etc but the name set_* implies that if we do the operation repeatedly, only the last value/call has effect - but the implementation does not satisfy this natural expectation - if we call set_bucket_name twice, it will append two conditions to the policy, possibly rendering it invalid - in the S3 spec, it seems these policy conditions are conjunctive (AND-ed together).
To solve this problem we need to fix that first, this has to be done perhaps in all libraries FWICS.
str(self._content_length_range[0]) + | ||
', ' + str(self._content_length_range[1]) + ']') | ||
policy_stmt = { | ||
"expiration": self._expiration.strftime( |
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.
why not do this in set_expires?
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.
See reply in comment about content-length-range.
import collections | ||
import fnmatch | ||
import itertools | ||
|
||
from .compat import basestring |
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.
can you update the licence header for these files as well pointing to '2015, 2016'.
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.
Do it wherever you are cleaning up.
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.
Done.
99e74f9
to
fd73fa8
Compare
No description provided.