You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defseek(self, offset: int, whence: int=0) ->int: # noqa: C901"""Seek the file object."""ifwhence==0:
loc=offsetelifwhence==1:
ifoffset>=0:
self.read(offset)
returnself.locloc=self.loc+offsetelifwhence==2:
ifnotself.size:
raiseValueError("cannot seek to the end of file")
loc=self.size+offsetelse:
raiseValueError(f"invalid whence ({whence}, should be 0, 1 or 2)")
ifloc<0:
raiseValueError("Seek before start of file")
iflocandnotself.supports_ranges:
raiseValueError("server does not support ranges")
self.close()
self._cm=iter_url(self.client, self.url, pos=loc, chunk_size=self.chunk_size)
# pylint: disable=no-member_, self._iterator=self._cm.__enter__()
self.loc=locreturnloc
when whence == 1 and offset > 0, the seek will read to the offset
to seek 1G later will read 1G content first, which is very inefficient
If I comment out the if statement, the seek operation works too, it will create a new iterator, use Range header to fast locate the position
The text was updated successfully, but these errors were encountered:
I think it was added assuming that on SEEK_CUR, the offsets are small, and might be already cached in our buffer and that I wanted to reset the iterator as much as possible (not all webdav servers support ranges).
In stream.py, seek function is
when whence == 1 and offset > 0, the seek will read to the offset
to seek 1G later will read 1G content first, which is very inefficient
If I comment out the if statement, the seek operation works too, it will create a new iterator, use Range header to fast locate the position
The text was updated successfully, but these errors were encountered: