mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 19:19:32 +01:00
Catch some sqlite exceptions that probably shouldn't be happening, but I
don't have the best of luck with sqlite.
This commit is contained in:
parent
21764931ec
commit
18138da1c0
@ -183,7 +183,11 @@ class URL(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
if len(url) >= minlen:
|
if len(url) >= minlen:
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
(tinyurl, updateDb) = self._getTinyUrl(url, channel)
|
try:
|
||||||
|
(tinyurl, updateDb) = self._getTinyUrl(url, channel)
|
||||||
|
except sqlite.OperationalError:
|
||||||
|
irc.error('The database just decided to crap itself.')
|
||||||
|
return
|
||||||
if tinyurl is None:
|
if tinyurl is None:
|
||||||
self.log.warning('tinyurl was None for url %r', url)
|
self.log.warning('tinyurl was None for url %r', url)
|
||||||
return
|
return
|
||||||
@ -236,9 +240,12 @@ class URL(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
def _getTinyUrl(self, url, channel, cmd=False):
|
def _getTinyUrl(self, url, channel, cmd=False):
|
||||||
db = self.getDb(channel)
|
db = self.getDb(channel)
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
cursor.execute("""SELECT tinyurls.tinyurl FROM urls, tinyurls
|
try:
|
||||||
WHERE urls.url=%s AND
|
cursor.execute("""SELECT tinyurls.tinyurl FROM urls, tinyurls
|
||||||
tinyurls.url_id=urls.id""", url)
|
WHERE urls.url=%s AND
|
||||||
|
tinyurls.url_id=urls.id""", url)
|
||||||
|
except sqlite.OperationalError:
|
||||||
|
raise
|
||||||
if cursor.rowcount == 0:
|
if cursor.rowcount == 0:
|
||||||
updateDb = True
|
updateDb = True
|
||||||
try:
|
try:
|
||||||
@ -299,8 +306,12 @@ class URL(callbacks.PrivmsgCommandAndRegexp,
|
|||||||
r = self.registryValue('nonSnarfingRegexp', channel)
|
r = self.registryValue('nonSnarfingRegexp', channel)
|
||||||
if snarf and len(url) >= minlen and not r.search(url):
|
if snarf and len(url) >= minlen and not r.search(url):
|
||||||
return
|
return
|
||||||
(tinyurl, updateDb) = self._getTinyUrl(url, channel, cmd=True)
|
try:
|
||||||
if tinyurl:
|
(tinyurl, updateDb) = self._getTinyUrl(url, channel, cmd=True)
|
||||||
|
except sqlite.OperationalError:
|
||||||
|
irc.error('The database just decided to crap itself.')
|
||||||
|
return
|
||||||
|
if tinyurl is not None:
|
||||||
if updateDb:
|
if updateDb:
|
||||||
self._updateTinyDb(url, tinyurl, channel)
|
self._updateTinyDb(url, tinyurl, channel)
|
||||||
irc.reply(tinyurl)
|
irc.reply(tinyurl)
|
||||||
|
Loading…
Reference in New Issue
Block a user