1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-01-04 06:21:46 +00:00

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

View file

@ -43,7 +43,10 @@ def add(self, item):
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)