]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
immutable: fix think-o in previous patch which caused all reads to return "", and...
authorZooko O'Whielacronx <zooko@zooko.com>
Sat, 3 Jan 2009 21:02:45 +0000 (14:02 -0700)
committerZooko O'Whielacronx <zooko@zooko.com>
Sat, 3 Jan 2009 21:02:45 +0000 (14:02 -0700)
src/allmydata/storage.py

index 1bed937d2204ac077baf9af54b41e16e0b343bd7..74eeaa840390ee6ec3b0291dfa5368c71f4df721 100644 (file)
@@ -138,12 +138,12 @@ class ShareFile:
         # reads beyond the end of the data are truncated. Reads that start beyond the end of the
         # data return an empty string.
         # I wonder why Python doesn't do the following computation for me?
-        f = open(self.home, 'rb')
         seekpos = self._data_offset+offset
         fsize = os.path.getsize(self.home)
-        actuallength = min(0, length, fsize-seekpos)
+        actuallength = max(0, min(length, fsize-seekpos))
         if actuallength == 0:
             return ""
+        f = open(self.home, 'rb')
         f.seek(seekpos)
         return f.read(actuallength)