fuse: add parameter check to ItemCache.get to make potential failures more clear

This commit is contained in:
Thomas Waldmann 2016-09-15 14:56:11 +02:00
parent 783d01f621
commit 5d22078f35
1 changed files with 4 additions and 1 deletions

View File

@ -43,7 +43,10 @@ class ItemCache:
return pos + self.offset
def get(self, inode):
self.fd.seek(inode - self.offset, io.SEEK_SET)
offset = inode - self.offset
if offset < 0:
raise ValueError('ItemCache.get() called with an invalid inode number')
self.fd.seek(offset, io.SEEK_SET)
item = next(msgpack.Unpacker(self.fd, read_size=1024))
return Item(internal_dict=item)