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
This commit is contained in:
Samuel Merritt 2012-11-07 13:36:35 -08:00
parent a69bc08990
commit d61dfb32e7
1 changed files with 1 additions and 1 deletions

View File

@ -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