You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2012/04/12 22:29:52 UTC
svn commit: r1325491 - /libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
Author: tomaz
Date: Thu Apr 12 20:29:52 2012
New Revision: 1325491
URL: http://svn.apache.org/viewvc?rev=1325491&view=rev
Log:
Fix FileChunkReader - should finish when end_block > self.total. Also reduce
nesting and return early.
Modified:
libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
Modified: libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py?rev=1325491&r1=1325490&r2=1325491&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/cloudfiles.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/cloudfiles.py Thu Apr 12 20:29:52 2012
@@ -708,21 +708,20 @@ class FileChunkReader(object):
return self
def next(self):
- if not self.stop_iteration:
- start_block = self.bytes_read
- end_block = start_block + self.chunk_size
- if end_block > self.total:
- end_block = self.total
- self.stop_iteration = True
- self.bytes_read += end_block - start_block
- return ChunkStreamReader(file_path=self.file_path,
- start_block=start_block,
- end_block=end_block,
- chunk_size=8192)
-
- else:
+ if self.stop_iteration:
raise StopIteration
+ start_block = self.bytes_read
+ end_block = start_block + self.chunk_size
+ if end_block >= self.total:
+ end_block = self.total
+ self.stop_iteration = True
+ self.bytes_read += end_block - start_block
+ return ChunkStreamReader(file_path=self.file_path,
+ start_block=start_block,
+ end_block=end_block,
+ chunk_size=8192)
+
class ChunkStreamReader(object):
def __init__(self, file_path, start_block, end_block, chunk_size):