Little refactoring for images: media_files.
authorElrond <elrond+mediagoblin.org@samba-tng.org>
Wed, 3 Apr 2013 16:49:46 +0000 (18:49 +0200)
committerElrond <elrond+mediagoblin.org@samba-tng.org>
Wed, 3 Apr 2013 16:49:46 +0000 (18:49 +0200)
Set the media_files directly at the relvant places.

mediagoblin/media_types/image/processing.py

index ca88d3f4ef29262c9a71eddea2eeba9de25b46d7..e951ef29676a286f028694e17dbf2ca5a3f2d6af 100644 (file)
@@ -122,6 +122,7 @@ def process_image(proc_state):
                 exif_tags, conversions_subdir,
                 (mgg.global_config['media:thumb']['max_width'],
                  mgg.global_config['media:thumb']['max_height']))
+    entry.media_files[u'thumb'] = thumb_filepath
 
     # If the size of the original file exceeds the specified size of a `medium`
     # file, a `.medium.jpg` files is created and later associated with the media
@@ -137,8 +138,7 @@ def process_image(proc_state):
             exif_tags, conversions_subdir,
             (mgg.global_config['media:medium']['max_width'],
              mgg.global_config['media:medium']['max_height']))
-    else:
-        medium_filepath = None
+        entry.media_files[u'medium'] = medium_filepath
 
     # Copy our queued local workbench to its final destination
     proc_state.copy_original(name_builder.fill('{basename}{ext}'))
@@ -146,12 +146,6 @@ def process_image(proc_state):
     # Remove queued media file from storage and database
     proc_state.delete_queue_file()
 
-    # Insert media file information into database
-    media_files_dict = entry.setdefault('media_files', {})
-    media_files_dict[u'thumb'] = thumb_filepath
-    if medium_filepath:
-        media_files_dict[u'medium'] = medium_filepath
-
     # Insert exif data into database
     exif_all = clean_exif(exif_tags)