Skip sniffing and reseting if retry is disabled
Bypass sniffing entirely if retries has been disabled. Fix bug #1216981 Change-Id: I593bdc56ca139af5a7f2ca2783ef2de2a96c94fb Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
This commit is contained in:
parent
0278998398
commit
dbdbaa0321
@ -1213,18 +1213,17 @@ class Connection(object):
|
|||||||
'ability to reset contents for reupload.'
|
'ability to reset contents for reupload.'
|
||||||
% (container, obj))
|
% (container, obj))
|
||||||
|
|
||||||
if isinstance(contents, str):
|
if isinstance(contents, str) or not contents:
|
||||||
# if its a str then you can retry as much as you want
|
# if its a str or None then you can retry as much as you want
|
||||||
reset_func = None
|
reset_func = None
|
||||||
else:
|
else:
|
||||||
reset_func = _default_reset
|
reset_func = _default_reset
|
||||||
tell = getattr(contents, 'tell', None)
|
if self.retries > 0:
|
||||||
seek = getattr(contents, 'seek', None)
|
tell = getattr(contents, 'tell', None)
|
||||||
if tell and seek:
|
seek = getattr(contents, 'seek', None)
|
||||||
orig_pos = tell()
|
if tell and seek:
|
||||||
reset_func = lambda *a, **k: seek(orig_pos)
|
orig_pos = tell()
|
||||||
elif not contents:
|
reset_func = lambda *a, **k: seek(orig_pos)
|
||||||
reset_func = lambda *a, **k: None
|
|
||||||
|
|
||||||
return self._retry(reset_func, put_object, container, obj, contents,
|
return self._retry(reset_func, put_object, container, obj, contents,
|
||||||
content_length=content_length, etag=etag,
|
content_length=content_length, etag=etag,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user