From: Christopher Allan Webber Date: Sun, 12 Jun 2011 02:20:39 +0000 (-0500) Subject: Switch process_media over to using the workbench. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ca030ab6cd5c18b7991f08a1ee103175f313c5a1;p=mediagoblin.git Switch process_media over to using the workbench. --- diff --git a/mediagoblin/process_media/__init__.py b/mediagoblin/process_media/__init__.py index 527c198c..1bb43755 100644 --- a/mediagoblin/process_media/__init__.py +++ b/mediagoblin/process_media/__init__.py @@ -26,11 +26,17 @@ THUMB_SIZE = 200, 200 @task def process_media_initial(media_id): + workbench = mg_globals.workbench_manager.create_workbench() + entry = mg_globals.database.MediaEntry.one( {'_id': ObjectId(media_id)}) queued_filepath = entry['queued_media_file'] - queued_file = mg_globals.queue_store.get_file(queued_filepath, 'r') + queued_filename = mg_globals.workbench_manager.possibly_localize_file( + workbench, mg_globals.queue_store, queued_filepath, + 'source') + + queued_file = file(queued_filename, 'r') with queued_file: thumb = Image.open(queued_file) @@ -47,7 +53,7 @@ def process_media_initial(media_id): # we have to re-read because unlike PIL, not everything reads # things in string representation :) - queued_file = mg_globals.queue_store.get_file(queued_filepath, 'rb') + queued_file = file(queued_filename, 'rb') with queued_file: main_filepath = mg_globals.public_store.get_unique_filepath( @@ -64,3 +70,6 @@ def process_media_initial(media_id): media_files_dict['main'] = main_filepath entry['state'] = u'processed' entry.save() + + # clean up workbench + mg_globals.workbench_manager.destroy_workbench(workbench)