From 3947a4fbd0223a40e6247df9477af9e0a47db753 Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Wed, 28 Aug 2013 00:39:48 -0400 Subject: [PATCH] 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 --- swift/common/utils.py | 6 +++++- swift/proxy/controllers/obj.py | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/swift/common/utils.py b/swift/common/utils.py index febeeaab72..4540858f8e 100644 --- a/swift/common/utils.py +++ b/swift/common/utils.py @@ -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 diff --git a/swift/proxy/controllers/obj.py b/swift/proxy/controllers/obj.py index 130d6ec14b..ca67b94a14 100644 --- a/swift/proxy/controllers/obj.py +++ b/swift/proxy/controllers/obj.py @@ -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',