mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +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()
|
||||||
|
try:
|
||||||
(tinyurl, updateDb) = self._getTinyUrl(url, channel)
|
(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()
|
||||||
|
try:
|
||||||
cursor.execute("""SELECT tinyurls.tinyurl FROM urls, tinyurls
|
cursor.execute("""SELECT tinyurls.tinyurl FROM urls, tinyurls
|
||||||
WHERE urls.url=%s AND
|
WHERE urls.url=%s AND
|
||||||
tinyurls.url_id=urls.id""", url)
|
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
|
||||||
|
try:
|
||||||
(tinyurl, updateDb) = self._getTinyUrl(url, channel, cmd=True)
|
(tinyurl, updateDb) = self._getTinyUrl(url, channel, cmd=True)
|
||||||
if tinyurl:
|
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