From: Christopher Allan Webber Date: Mon, 12 Aug 2013 13:22:14 +0000 (-0500) Subject: Record the original state of the media entry in the processor X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=22479c39a0fff75208309e437f5fdaf57730cf0e;p=mediagoblin.git Record the original state of the media entry in the processor This allows our processor to make some informed decisions based on the state by still having access to the original state. This commit sponsored by William Rico. Thank you! --- diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index 02dba2f9..47f0b84e 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -116,6 +116,7 @@ class MediaProcessor(object): def __init__(self, manager, media_entry): self.manager = manager self.media_entry = media_entry + self.entry_orig_state = media_entry.state # Should be initialized at time of processing, at least self.workbench = None diff --git a/mediagoblin/processing/task.py b/mediagoblin/processing/task.py index 397514d0..d3770588 100644 --- a/mediagoblin/processing/task.py +++ b/mediagoblin/processing/task.py @@ -85,12 +85,14 @@ class ProcessMedia(task.Task): try: processor_class = manager.get_processor(reprocess_action, entry) - entry.state = u'processing' - entry.save() + with processor_class(manager, entry) as processor: + # Initial state change has to be here because + # the entry.state gets recorded on processor_class init + entry.state = u'processing' + entry.save() - _log.debug('Processing {0}'.format(entry)) + _log.debug('Processing {0}'.format(entry)) - with processor_class(manager, entry) as processor: processor.process(**reprocess_info) # We set the state to processed and save the entry here so there's