mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-11 21:53:37 +00:00
Fixed duplicate tv cache issue.
This commit is contained in:
parent
c3e2ff5193
commit
cfbb7678a9
1 changed files with 8 additions and 9 deletions
|
@ -55,8 +55,14 @@ class CacheDBConnection(db.DBConnection):
|
||||||
self.action(
|
self.action(
|
||||||
"CREATE TABLE [" + providerName + "] (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT)")
|
"CREATE TABLE [" + providerName + "] (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT)")
|
||||||
else:
|
else:
|
||||||
# remove duplicates
|
sqlResults = self.select(
|
||||||
self.action("DELETE FROM " + providerName + " WHERE url NOT IN (SELECT url FROM " + providerName + " GROUP BY url)")
|
"SELECT url, COUNT(url) as count FROM [" + providerName + "] GROUP BY url HAVING count > 1")
|
||||||
|
|
||||||
|
for cur_dupe in sqlResults:
|
||||||
|
self.action("DELETE FROM [" + providerName + "] WHERE url = ?", [cur_dupe["url"]])
|
||||||
|
|
||||||
|
# add unique index to prevent further dupes from happening if one does not exist
|
||||||
|
self.action("CREATE UNIQUE INDEX IF NOT EXISTS idx_url ON " + providerName + " (url)")
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
if str(e) != "table [" + providerName + "] already exists":
|
if str(e) != "table [" + providerName + "] already exists":
|
||||||
raise
|
raise
|
||||||
|
@ -69,13 +75,6 @@ class CacheDBConnection(db.DBConnection):
|
||||||
if str(e) != "table lastUpdate already exists":
|
if str(e) != "table lastUpdate already exists":
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
# Create unique index for provider table to prevent duplicate entries
|
|
||||||
try:
|
|
||||||
self.action("CREATE UNIQUE INDEX IF NOT EXISTS idx_url ON " + providerName + " (url)")
|
|
||||||
except Exception, e:
|
|
||||||
raise
|
|
||||||
|
|
||||||
class TVCache():
|
class TVCache():
|
||||||
def __init__(self, provider):
|
def __init__(self, provider):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue