From d61dfb32e717425fab21061152d7354539d86f00 Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Wed, 7 Nov 2012 13:36:35 -0800 Subject: [PATCH] Use computed size on object PUT, not fstat. The object server knows the size of the file on disk already since it's counted the bytes as they were written out. There's no need to go ask the filesystem. This also lets object PUTs work when the filesystem is some crazy, non-POSIX thing that doesn't always give the right answers from fstat(). See bug 904723 for a case when this happened. Fixes bug 904723. Change-Id: Ibdf44ea991e0cc4f9e0997cc9ff566cb0eac5332 --- swift/obj/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift/obj/server.py b/swift/obj/server.py index ec84c2da23..cea7693e2b 100755 --- a/swift/obj/server.py +++ b/swift/obj/server.py @@ -631,7 +631,7 @@ class ObjectController(object): 'X-Timestamp': request.headers['x-timestamp'], 'Content-Type': request.headers['content-type'], 'ETag': etag, - 'Content-Length': str(os.fstat(fd).st_size), + 'Content-Length': str(upload_size), } metadata.update(val for val in request.headers.iteritems() if val[0].lower().startswith('x-object-meta-') and