Failsafe incase view is named after existing tag

After the initial sync already completed.
This commit is contained in:
angelblue05 2016-01-09 03:03:39 -06:00
parent 77dd006f21
commit b61b8ae894

View file

@ -852,6 +852,7 @@ class Kodidb_Functions():
if self.kodiversion in (15, 16):
# Kodi Isengard, Jarvis
try:
query = ' '.join((
"UPDATE tag_link",
@ -861,8 +862,21 @@ class Kodidb_Functions():
"AND tag_id = ?"
))
cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
except Exception as e:
# The new tag we are going to apply already exists for this item
# delete current tag instead
self.logMsg("Exception: %s" % e, 1)
query = ' '.join((
"DELETE FROM tag_link",
"WHERE media_id = ?",
"AND media_type = ?",
"AND tag_id = ?"
))
cursor.execute(query, (kodiid, mediatype, oldtag,))
else:
# Kodi Helix
try:
query = ' '.join((
"UPDATE taglinks",
@ -872,6 +886,18 @@ class Kodidb_Functions():
"AND idTag = ?"
))
cursor.execute(query, (newtag, kodiid, mediatype, oldtag,))
except Exception as e:
# The new tag we are going to apply already exists for this item
# delete current tag instead
self.logMsg("Exception: %s" % e, 1)
query = ' '.join((
"DELETE FROM taglinks",
"WHERE idMedia = ?",
"AND media_type = ?",
"AND idTag = ?"
))
cursor.execute(query, (kodiid, mediatype, oldtag,))
def removeTag(self, kodiid, tagname, mediatype):