From 1f180a5a05c38491db1589c10a1dae7bb5f72376 Mon Sep 17 00:00:00 2001 From: echel0n Date: Sat, 7 Jun 2014 16:16:01 -0700 Subject: [PATCH] Fix for closing cache connection early when needed. --- sickbeard/tvcache.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py index 055bd961..ac09042b 100644 --- a/sickbeard/tvcache.py +++ b/sickbeard/tvcache.py @@ -49,22 +49,21 @@ class CacheDBConnection(db.DBConnection): def __init__(self, providerName): db.DBConnection.__init__(self, "cache.db") - with self as myDB: - # Create the table if it's not already there - try: - if not myDB.hasTable(providerName): - myDB.action("CREATE TABLE [" + providerName + "] (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT)") - except Exception, e: - if str(e) != "table [" + providerName + "] already exists": - raise + # Create the table if it's not already there + try: + if not self.hasTable(providerName): + self.action("CREATE TABLE [" + providerName + "] (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT)") + except Exception, e: + if str(e) != "table [" + providerName + "] already exists": + raise - # Create the table if it's not already there - try: - if not myDB.hasTable('lastUpdate'): - myDB.action("CREATE TABLE lastUpdate (provider TEXT, time NUMERIC)") - except Exception, e: - if str(e) != "table lastUpdate already exists": - raise + # Create the table if it's not already there + try: + if not self.hasTable('lastUpdate'): + self.action("CREATE TABLE lastUpdate (provider TEXT, time NUMERIC)") + except Exception, e: + if str(e) != "table lastUpdate already exists": + raise class TVCache():