Ticket #5071: issue_5071.patch

File issue_5071.patch, 1.8 KB (added by Boris Bobrov, 10 years ago)
  • mediagoblin/media_types/video/migrations.py

    From b605253f334a208d7f651d17c949a75bb084aa58 Mon Sep 17 00:00:00 2001
    From: Boris Bobrov <breton@cynicmansion.ru>
    Date: Fri, 20 Mar 2015 02:43:16 +0300
    Subject: [PATCH] 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
    ---
     mediagoblin/media_types/video/migrations.py |    8 ++++----
     1 file changed, 4 insertions(+), 4 deletions(-)
    
    diff --git a/mediagoblin/media_types/video/migrations.py b/mediagoblin/media_types/video/migrations.py
    index 8088220..2445cd4 100644
    a b def change_metadata_format(db):  
    5959    vid_data = inspect_table(db_metadata, "video__mediadata")
    6060
    6161    for row in db.execute(vid_data.select()):
    62         metadata = json.loads(row.orig_metadata)
    63 
    64         if not metadata:
     62        if not row.orig_metadata:
    6563            continue
    6664
     65        metadata = json.loads(row.orig_metadata)
     66
    6767        # before this migration there was info about only one video or audio
    6868        # stream. So, we store existing info as the first item in the list
    6969        new_metadata = {'audio': [], 'video': [], 'common': {}}
    def change_metadata_format(db):  
    8585                for k, v in audio_key_map.items() if metadata.get(k))]
    8686        new_metadata['common'] = dict((v, metadata.get(k))
    8787                for k, v in common_key_map.items() if metadata.get(k))
    88        
     88
    8989        # 'mimetype' should be in tags
    9090        new_metadata['common']['tags'] = {'mimetype': metadata.get('mimetype')}
    9191        if 'tags' in metadata: