From: Rodney Ewing Date: Fri, 2 Aug 2013 22:20:59 +0000 (-0700) Subject: change get_queued_filename to get_orig_filename and modified function X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=45b20dce1ac5a8d9fb045faf67e796a8092f65e4;p=mediagoblin.git change get_queued_filename to get_orig_filename and modified function --- diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py index 078ab0d8..665a2931 100644 --- a/mediagoblin/media_types/image/processing.py +++ b/mediagoblin/media_types/image/processing.py @@ -75,7 +75,7 @@ def resize_image(proc_state, resized, keyname, target_name, new_size, def resize_tool(proc_state, force, keyname, target_name, conversions_subdir, exif_tags, new_size=None): - # Get the filename of the original file + # filename -- the filename of the original image being resized filename = proc_state.get_orig_filename() # Use the default size if new_size was not given diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index 13c677eb..60565e09 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -86,27 +86,37 @@ class ProcessingState(object): def __init__(self, entry): self.entry = entry self.workbench = None - self.queued_filename = None - self.reprocess_filename = None + self.orig_filename = None def set_workbench(self, wb): self.workbench = wb - def get_queued_filename(self): + def get_orig_filename(self): """ Get the a filename for the original, on local storage + + If the media entry has a queued_media_file, use that, otherwise + use the original. + + In the future, this will return the highest quality file available + if neither the original or queued file are available """ - if self.queued_filename is not None: - return self.queued_filename - queued_filepath = self.entry.queued_media_file - queued_filename = self.workbench.localized_file( - mgg.queue_store, queued_filepath, + if self.orig_filename is not None: + return self.orig_filename + + if self.entry.queued_media_file: + orig_filepath = self.entry.queued_media_file + else: + orig_filepath = self.entry.media_files['original'] + + orig_filename = self.workbench.localized_file( + mgg.queue_store, orig_filepath, 'source') - self.queued_filename = queued_filename - return queued_filename + self.orig_filename = orig_filename + return orig_filename def copy_original(self, target_name, keyname=u"original"): - self.store_public(keyname, self.get_queued_filename(), target_name) + self.store_public(keyname, self.get_orig_filename(), target_name) def store_public(self, keyname, local_file, target_name=None): if target_name is None: @@ -129,22 +139,6 @@ class ProcessingState(object): mgg.queue_store.delete_dir(queued_filepath[:-1]) # rm dir self.entry.queued_media_file = [] - def get_reprocess_filename(self): - """ - Get the filename to use during reprocessing - """ - # Currently only returns the original file, but eventually will return - # the highest quality file if the original doesn't exist - if self.reprocess_filename is not None: - return self.reprocess_filename - - reprocess_filepath = self.entry.media_files['original'] - reprocess_filename = self.workbench.localized_file( - mgg.public_store, reprocess_filepath, - 'source') - self.reprocess_filename = reprocess_filename - return reprocess_filename - def mark_entry_failed(entry_id, exc): """