summaryrefslogtreecommitdiff
path: root/glance_store/_drivers
diff options
context:
space:
mode:
authorJake Yip <jake.yip@unimelb.edu.au>2018-10-03 13:28:40 +1000
committerJake Yip <jake.yip@unimelb.edu.au>2019-09-06 11:01:56 +1000
commitff45bb89811e2266cda1509086668e08d7282a96 (patch)
tree4ccd7a1cdc1a40c166cab7103141710586c110c7 /glance_store/_drivers
parent5d86e1a5c25725dde288082ce45e7c2c55ae747f (diff)
downloadglance_store-ff45bb89811e2266cda1509086668e08d7282a96.tar.gz
Set zero size only when nothing is written
There is a bug where is_zero_size is set when the loop is exited, regardless of whether any data was written in the while loop, making it seems like 0 bytes were written. We need to differentiate an exit with no data written and and exit with, so we test if anything was actually written and only set is_zero_size when nothing has been written. Also, bytes_read gets resetted to 0 with the next line seek(0), so we check before resetting the file position. Change-Id: I547bdefe88816db85b5ff510e997980269eac1f7
Diffstat (limited to 'glance_store/_drivers')
-rw-r--r--glance_store/_drivers/swift/buffered.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/glance_store/_drivers/swift/buffered.py b/glance_store/_drivers/swift/buffered.py
index 898d156..d852922 100644
--- a/glance_store/_drivers/swift/buffered.py
+++ b/glance_store/_drivers/swift/buffered.py
@@ -149,9 +149,10 @@ class BufferedReader(object):
# possible set of errors.
raise socket.error(*e.args)
if len(buf) == 0:
+ if self._tmpfile.tell() == 0:
+ self.is_zero_size = True
self._tmpfile.seek(0)
self._buffered = True
- self.is_zero_size = True
break
self._tmpfile.write(buf)
to_buffer -= len(buf)