run migrations in separate thread; don't fail on already run history migration

This commit is contained in:
pannal committed 2017-03-07 10:04:44 +01:00
1 parent fa57f23218
commit b3752ebea0
2 files changed
+12 -8

No files matched your search

+3 -5
View File
@@ -33,7 +33,7 @@ from support.config import config
from support.lib import get_intent
from support.helpers import track_usage, get_title_for_video_metadata, get_identifier, cast_bool
from support.history import get_history
from support.data import migrate
from support.data import dispatch_migrate
def Start():
@@ -55,10 +55,8 @@ def Start():
del Dict["menu_history"][key]
# run migrations
try:
migrate()
except:
Log.Error("Migration failed: %s" % traceback.format_exc())
if "subs" in Dict or "history" in Dict:
Thread.Create(dispatch_migrate)
# clear old task data
scheduler.clear_task_data()
+9 -3
View File
@@ -1,5 +1,11 @@
# coding=utf-8
from urllib2 import URLError
def dispatch_migrate():
try:
migrate()
except:
Log.Error("Migration failed: %s" % traceback.format_exc())
def migrate():
@@ -9,7 +15,7 @@ def migrate():
"""
# migrate subtitle history from Dict to Data
if "history" in Dict and Dict["history"]["history_items"]:
if "history" in Dict and Dict["history"].get("history_items"):
Log.Debug("Running migration for history data")
from support.history import get_history
history = get_history()
@@ -32,7 +38,7 @@ def migrate():
for video_id, parts in Dict["subs"].iteritems():
try:
item = get_item(video_id)
except URLError:
except:
continue
if not item: