State file corrupted after full disk

It seems that when the disk is full, sbws corrupts its state file (completely truncates it) rather than noticing and not touching it. On subsequent runs of generate, sbws chokes on the empty file:

Traceback (most recent call last):
 File "/usr/bin/sbws", line 33, in <module>
   sys.exit(load_entry_point('sbws==1.5.2', 'console_scripts', 'sbws')())
 File "/usr/lib/python3/dist-packages/sbws/sbws.py", line 93, in main
   exit(comm["f"](*comm["a"], **comm["kw"]))
 File "/usr/lib/python3/dist-packages/sbws/core/generate.py", line 174, in main
   bw_file = V3BWFile.from_results(
 File "/usr/lib/python3/dist-packages/sbws/lib/v3bwfile.py", line 1129, in from_results
   header = V3BWHeader.from_results(
 File "/usr/lib/python3/dist-packages/sbws/lib/v3bwfile.py", line 373, in from_results
   generator_started = cls.generator_started_from_file(state_fpath)
 File "/usr/lib/python3/dist-packages/sbws/lib/v3bwfile.py", line 485, in generator_started_from_file
   state = State(state_fpath)
 File "/usr/lib/python3/dist-packages/sbws/util/state.py", line 47, in __init__
   self._state = self._read()
 File "/usr/lib/python3/dist-packages/sbws/util/state.py", line 54, in _read
   return json.load(fd, cls=CustomDecoder)
 File "/usr/lib/python3.9/json/__init__.py", line 293, in load
   return loads(fp.read(),
 File "/usr/lib/python3.9/json/__init__.py", line 359, in loads
   return cls(**kw).decode(s)
 File "/usr/lib/python3/dist-packages/sbws/util/json.py", line 24, in decode
   decoded = super().decode(s, **kwargs)
 File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
   obj, end = self.raw_decode(s, idx=_w(s, 0).end())
 File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
   raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

It started working again after I removed the empty state file

Edited by Sebastian Hahn