[ARVADOS] updated: 583e9e1e9672d3eb0a317d371acbb83b9ab840ec

git at public.curoverse.com git at public.curoverse.com
Mon Aug 4 13:43:55 EDT 2014


Summary of changes:
 sdk/python/arvados/stream.py         |  2 +-
 sdk/python/tests/test_collections.py | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

       via  583e9e1e9672d3eb0a317d371acbb83b9ab840ec (commit)
      from  80b502ea52e896d7bb42cc566f7472e6cd4fe397 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 583e9e1e9672d3eb0a317d371acbb83b9ab840ec
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Aug 4 13:43:18 2014 -0400

    Fix bug in StreamFileReader incorrectly updating self._filepos resulting in
    incomplete file reads.  closes #3466

diff --git a/sdk/python/arvados/stream.py b/sdk/python/arvados/stream.py
index cbd1ba9..fd84435 100644
--- a/sdk/python/arvados/stream.py
+++ b/sdk/python/arvados/stream.py
@@ -137,7 +137,7 @@ class StreamFileReader(object):
         data = ''
         for locator, blocksize, segmentoffset, segmentsize in locators_and_ranges(self.segments, self._filepos, size):
             data += self._stream.readfrom(locator+segmentoffset, segmentsize)
-            self._filepos += len(data)
+        self._filepos += len(data)
         return data
 
     def readfrom(self, start, size):
diff --git a/sdk/python/tests/test_collections.py b/sdk/python/tests/test_collections.py
index 7483ba0..5354f3a 100644
--- a/sdk/python/tests/test_collections.py
+++ b/sdk/python/tests/test_collections.py
@@ -436,6 +436,26 @@ class ArvadosCollectionsTest(ArvadosKeepLocalStoreTestCase):
         self.assertEqual(sr.readfrom(25, 5), content[25:30])
         self.assertEqual(sr.readfrom(30, 5), '')
 
+    def test_file_reader(self):
+        keepblocks = {'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa+10': 'abcdefghij',
+                      'bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb+15': 'klmnopqrstuvwxy',
+                      'cccccccccccccccccccccccccccccccc+5': 'z0123'}
+        mk = self.MockKeep(keepblocks)
+
+        sr = arvados.StreamReader([".", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa+10", "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb+15", "cccccccccccccccccccccccccccccccc+5", "0:10:foo", "15:10:foo"], mk)
+
+        content = 'abcdefghijpqrstuvwxy'
+
+        f = sr.files()["foo"]
+
+        f.seek(0)
+        self.assertEqual(f.read(20), content[0:20])
+
+        f.seek(0)
+        self.assertEqual(f.read(6), content[0:6])
+        self.assertEqual(f.read(6), content[6:12])
+        self.assertEqual(f.read(6), content[12:18])
+
     def test_extract_file(self):
         m1 = """. 5348b82a029fd9e971a811ce1f71360b+43 0:43:md5sum.txt
 . 085c37f02916da1cad16f93c54d899b7+41 0:41:md6sum.txt

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list