more resilience
This commit is contained in:
parent
76512dfa2d
commit
f5dc4cb71e
@ -35,3 +35,6 @@ class FileDict:
|
|||||||
return marshal.load(f)
|
return marshal.load(f)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return {}
|
return {}
|
||||||
|
except Exception:
|
||||||
|
logging.warning("corrupt marshal data at: %r", self.path)
|
||||||
|
return {}
|
||||||
|
@ -22,3 +22,10 @@ def test_dying_lock(tmp_path, caplog):
|
|||||||
d["1"] = "3"
|
d["1"] = "3"
|
||||||
assert fdict1.read()["1"] == "3"
|
assert fdict1.read()["1"] == "3"
|
||||||
assert fdict2.read()["1"] == "3"
|
assert fdict2.read()["1"] == "3"
|
||||||
|
|
||||||
|
|
||||||
|
def test_bad_marshal_file(tmp_path, caplog):
|
||||||
|
fdict1 = FileDict(tmp_path.joinpath("metadata"))
|
||||||
|
fdict1.path.write_bytes(b"l12k3l12k3l")
|
||||||
|
assert fdict1.read() == {}
|
||||||
|
assert "corrupt" in caplog.records[0].msg
|
||||||
|
Loading…
Reference in New Issue
Block a user