From 94cecc240b03771ce318492e9d30e7a1249397b6 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Thu, 9 Dec 2010 03:33:53 -0800 Subject: [PATCH] Don't abort if 'insert into Files' gives an IntegrityError. It can happen occasionally if some other parallel redo adds the same file at the same time. --- state.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/state.py b/state.py index beac06e..df41a5b 100644 --- a/state.py +++ b/state.py @@ -163,7 +163,12 @@ class File(object): if not name: raise Exception('File with id=%r not found and ' 'name not given' % id) - _write('insert into Files (name) values (?)', [name]) + try: + _write('insert into Files (name) values (?)', [name]) + except sqlite3.IntegrityError: + # some parallel redo probably added it at the same time; no + # big deal. + pass row = d.execute(q, l).fetchone() assert(row) self._init_from_cols(row)