From 23caf305f28d1e8baf5196703ac316cfe4e740dc Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Mon, 12 Dec 2011 08:10:10 -0600 Subject: [PATCH] Allow administrators to disable keeping the original. That's the new default! --- mediagoblin/config_spec.ini | 5 ++++ mediagoblin/media_types/video/processing.py | 29 +++++++++++---------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/mediagoblin/config_spec.ini b/mediagoblin/config_spec.ini index 13ce925e..eb22bc1b 100644 --- a/mediagoblin/config_spec.ini +++ b/mediagoblin/config_spec.ini @@ -61,6 +61,11 @@ storage_class = string(default="mediagoblin.storage.filestorage:BasicFileStorage base_dir = string(default="%(here)s/user_dev/media/queue") +# Should we keep the original file? +[media_type:mediagoblin.media_types.video] +keep_original = boolean(default=False) + + [beaker.cache] type = string(default="file") data_dir = string(default="%(here)s/user_dev/beaker/cache/data") diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py index 6125e49c..c0a3fb67 100644 --- a/mediagoblin/media_types/video/processing.py +++ b/mediagoblin/media_types/video/processing.py @@ -41,6 +41,8 @@ def process_video(entry): and attaches callbacks to that child process, hopefully, the entry-complete callback will be called when the video is done. """ + video_config = mgg.global_config['media_type:mediagoblin.media_types.video'] + workbench = mgg.workbench_manager.create_workbench() queued_filepath = entry['queued_media_file'] @@ -94,25 +96,24 @@ def process_video(entry): entry['media_files']['thumb'] = thumbnail_filepath + if video_config['keep_original']: + # Push original file to public storage + queued_file = file(queued_filename, 'rb') - # Push original file to public storage - queued_file = file(queued_filename, 'rb') - - with queued_file: - original_filepath = create_pub_filepath( - entry, - queued_filepath[-1]) + with queued_file: + original_filepath = create_pub_filepath( + entry, + queued_filepath[-1]) - with mgg.public_store.get_file(original_filepath, 'wb') as \ - original_file: - _log.debug('Saving original...') - original_file.write(queued_file.read()) - _log.debug('Saved original') + with mgg.public_store.get_file(original_filepath, 'wb') as \ + original_file: + _log.debug('Saving original...') + original_file.write(queued_file.read()) + _log.debug('Saved original') - entry['media_files']['original'] = original_filepath + entry['media_files']['original'] = original_filepath mgg.queue_store.delete_file(queued_filepath) - # Save the MediaEntry entry.save() -- 2.25.1