Don't use float() when normalize_timestamp() does it.
And add a comment to note for the curious when the current timestamp will bump to 11 digits of seconds (which implies that one would no longer be able to use string compare on timestamps of differing length). Change-Id: I823e7659c41a54915d7c9c64c9161a29e79cd48c Signed-off-by: Peter Portante <peter.portante@redhat.com>
This commit is contained in:
parent
61a8a9af18
commit
3947a4fbd0
@ -425,7 +425,11 @@ def drop_buffer_cache(fd, offset, length):
|
||||
def normalize_timestamp(timestamp):
|
||||
"""
|
||||
Format a timestamp (string or numeric) into a standardized
|
||||
xxxxxxxxxx.xxxxx format.
|
||||
xxxxxxxxxx.xxxxx (10.5) format.
|
||||
|
||||
Note that timestamps using values greater than or equal to November 20th,
|
||||
2286 at 17:46 UTC will use 11 digits to represent the number of
|
||||
seconds.
|
||||
|
||||
:param timestamp: unix timestamp
|
||||
:returns: normalized timestamp as a string
|
||||
|
@ -861,7 +861,7 @@ class ObjectController(Controller):
|
||||
if 'x-timestamp' in req.headers:
|
||||
try:
|
||||
req.headers['X-Timestamp'] = \
|
||||
normalize_timestamp(float(req.headers['x-timestamp']))
|
||||
normalize_timestamp(req.headers['x-timestamp'])
|
||||
if hresp.environ and 'swift_x_timestamp' in hresp.environ and \
|
||||
float(hresp.environ['swift_x_timestamp']) >= \
|
||||
float(req.headers['x-timestamp']):
|
||||
@ -1210,7 +1210,7 @@ class ObjectController(Controller):
|
||||
if 'x-timestamp' in req.headers:
|
||||
try:
|
||||
req.headers['X-Timestamp'] = \
|
||||
normalize_timestamp(float(req.headers['x-timestamp']))
|
||||
normalize_timestamp(req.headers['x-timestamp'])
|
||||
except ValueError:
|
||||
return HTTPBadRequest(
|
||||
request=req, content_type='text/plain',
|
||||
|
Loading…
x
Reference in New Issue
Block a user