mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-04-08 19:34:18 +00:00
immutable: tolerate filenode.read() with a size= that's too big, rather than hanging
This commit is contained in:
parent
cef24792e7
commit
6fa41e738b
@ -221,7 +221,7 @@ class FileNode(_ImmutableFileNodeBase):
|
||||
def read(self, consumer, offset=0, size=None):
|
||||
if size is None:
|
||||
size = self.get_size() - offset
|
||||
|
||||
size = min(size, self.get_size() - offset)
|
||||
|
||||
if offset == 0 and size == self.get_size():
|
||||
# don't use the cache, just do a normal streaming download
|
||||
|
@ -202,6 +202,11 @@ class SystemTest(SystemTestMixin, unittest.TestCase):
|
||||
def _read_tail_done(mc):
|
||||
self.failUnlessEqual("".join(mc.chunks), DATA[2:])
|
||||
d.addCallback(_read_tail_done)
|
||||
d.addCallback(lambda ign:
|
||||
n.read(MemoryConsumer(), size=len(DATA)+1000))
|
||||
def _read_too_much(mc):
|
||||
self.failUnlessEqual("".join(mc.chunks), DATA)
|
||||
d.addCallback(_read_too_much)
|
||||
|
||||
return d
|
||||
d.addCallback(_test_read)
|
||||
|
Loading…
x
Reference in New Issue
Block a user