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.
This commit is contained in:
Avery Pennarun 2010-12-09 03:33:53 -08:00
commit 94cecc240b

View file

@ -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)