aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Bobrov <breton@cynicmansion.ru>2015-03-20 02:43:16 +0300
committerChristopher Allan Webber <cwebber@dustycloud.org>2015-04-23 11:48:23 -0500
commit3510f94811adfaa2bba0965686da8abe6c7e2c6d (patch)
tree36d1bc4f820008ed196cab750050b69b0674dd1c
parenta1bde56fd2e367cc100b28dffb41ddb9d730f272 (diff)
downloadmediagoblin-3510f94811adfaa2bba0965686da8abe6c7e2c6d.tar.lz
mediagoblin-3510f94811adfaa2bba0965686da8abe6c7e2c6d.tar.xz
mediagoblin-3510f94811adfaa2bba0965686da8abe6c7e2c6d.zip
Move check that metadata exists earlier
Because of gstreamer-1.0 we need to migrate from old format of storing metadata to new one. It seems that there are cases when original metadata is empty for some reason. The patch adds an earlier check that original metadata exists, skipping everything is it doesn't. Closes bug 5071
-rw-r--r--mediagoblin/media_types/video/migrations.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/mediagoblin/media_types/video/migrations.py b/mediagoblin/media_types/video/migrations.py
index 8088220b..2445cd4d 100644
--- a/mediagoblin/media_types/video/migrations.py
+++ b/mediagoblin/media_types/video/migrations.py
@@ -59,11 +59,11 @@ def change_metadata_format(db):
vid_data = inspect_table(db_metadata, "video__mediadata")
for row in db.execute(vid_data.select()):
- metadata = json.loads(row.orig_metadata)
-
- if not metadata:
+ if not row.orig_metadata:
continue
+ metadata = json.loads(row.orig_metadata)
+
# before this migration there was info about only one video or audio
# stream. So, we store existing info as the first item in the list
new_metadata = {'audio': [], 'video': [], 'common': {}}
@@ -85,7 +85,7 @@ def change_metadata_format(db):
for k, v in audio_key_map.items() if metadata.get(k))]
new_metadata['common'] = dict((v, metadata.get(k))
for k, v in common_key_map.items() if metadata.get(k))
-
+
# 'mimetype' should be in tags
new_metadata['common']['tags'] = {'mimetype': metadata.get('mimetype')}
if 'tags' in metadata: