hope i fixed the bug

This commit is contained in:
blank X 2021-04-08 11:11:14 +07:00
parent d0d7009886
commit d05e04e73a
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 15 additions and 9 deletions

View File

@ -14,7 +14,8 @@ class CappedBufferedReader(io.BufferedReader):
return super().read(size)
def seek(self, offset, whence=os.SEEK_SET):
if offset == 0 and whence == os.SEEK_END and self.capped_size is not None:
if self.capped_size is not NOne:
if offset == 0 and whence == os.SEEK_END:
if self.capped_size < 0:
offset = 0
else:
@ -23,7 +24,12 @@ class CappedBufferedReader(io.BufferedReader):
offset = real_end
else:
offset = self.capped_size
self.capped_size -= offset
whence = os.SEEK_SET
elif whence == os.SEEK_SET:
current_pos = self.tell()
if current_pos > offset:
self.capped_size += current_pos - offset
return super().seek(offset, whence)
@property