diff --git a/ui/medashare/btv/__init__.py b/ui/medashare/btv/__init__.py index 86004fd..641ce61 100644 --- a/ui/medashare/btv/__init__.py +++ b/ui/medashare/btv/__init__.py @@ -196,8 +196,11 @@ def validate(torrent, basedir, with_file_hashes=None): def apply_fun(data, fname, offset): if with_file_hashes is not None: - hashobj, curoff = file_hashes.setdefault(fname, - (with_file_hashes(), 0)) + try: + hashobj, curoff = file_hashes[fname] + except KeyError: + hashobj, curoff = with_file_hashes(), 0 + file_hashes[fname] = hashobj, curoff if curoff == offset: hashobj.update(data)