diff --git a/hermit/shards/shard_set.py b/hermit/shards/shard_set.py index 66412c0..8a9c7c7 100644 --- a/hermit/shards/shard_set.py +++ b/hermit/shards/shard_set.py @@ -69,7 +69,7 @@ def _ensure_shards(self, shards_expected: bool = True) -> None: # If for some reason the persistence layer failed to create the # the shards file, we assume that we just need to initialize # it as an empty bson object. - if not os.path.exists(self.config.shards_file): + if not os.path.exists(self.config.shards_file) or os.stat(self.config.shards_file).st_size == 0: with open(self.config.shards_file, 'wb') as f: f.write(bson.dumps({}))