summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2022-08-14 16:26:10 +0200
committerAnton Khirnov <anton@khirnov.net>2022-08-14 16:26:10 +0200
commit4ba0cdfb017988c3c19101780b1049480724193b (patch)
treef0486725cb17132e115355fb01c98b9d4afe4fb8
parent6e2085b798ddadfc34625e5897f45fbcac8abad9 (diff)
repository: return None when stats file cannot be parsed
Typically happens on the first run, when there's just one entry, so variance cannot be computed.
-rw-r--r--lbup/repository.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/lbup/repository.py b/lbup/repository.py
index 398c912..6b7c54b 100644
--- a/lbup/repository.py
+++ b/lbup/repository.py
@@ -136,4 +136,8 @@ class Repo:
def read_stats(self, tgt_name):
filename = os.path.join(self.data_dir, tgt_name, self.sizestat_name)
- return BackupStats(filename)
+ try:
+ return BackupStats(filename)
+ except statistics.StatisticsError:
+ self._logger.warning('Could not read statistics file: %s', filename)
+ return None