From 13cbffb6d485828e73359df9def28a79176faa04 Mon Sep 17 00:00:00 2001 From: echel0n Date: Thu, 26 Jun 2014 03:29:05 -0700 Subject: [PATCH] Deletes duplicates found in tv provider cache before creating unique index for provider table or just performs cleanup of any duplicate record period. --- sickbeard/tvcache.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sickbeard/tvcache.py b/sickbeard/tvcache.py index 63fd4e1a..457f04e4 100644 --- a/sickbeard/tvcache.py +++ b/sickbeard/tvcache.py @@ -54,6 +54,9 @@ class CacheDBConnection(db.DBConnection): if not self.hasTable(providerName): self.action( "CREATE TABLE [" + providerName + "] (name TEXT, season NUMERIC, episodes TEXT, indexerid NUMERIC, url TEXT, time NUMERIC, quality TEXT)") + else: + # remove duplicates + self.action("DELETE FROM " + providerName + " WHERE url NOT IN (SELECT url FROM " + providerName + " GROUP BY url") except Exception, e: if str(e) != "table [" + providerName + "] already exists": raise