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:
parent
3ef2bd7300
commit
94cecc240b
1 changed files with 6 additions and 1 deletions
7
state.py
7
state.py
|
|
@ -163,7 +163,12 @@ class File(object):
|
||||||
if not name:
|
if not name:
|
||||||
raise Exception('File with id=%r not found and '
|
raise Exception('File with id=%r not found and '
|
||||||
'name not given' % id)
|
'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()
|
row = d.execute(q, l).fetchone()
|
||||||
assert(row)
|
assert(row)
|
||||||
self._init_from_cols(row)
|
self._init_from_cols(row)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue