Record the original state of the media entry in the processor
authorChristopher Allan Webber <cwebber@dustycloud.org>
Mon, 12 Aug 2013 13:22:14 +0000 (08:22 -0500)
committerRodney Ewing <ewing.rj@gmail.com>
Fri, 16 Aug 2013 22:30:16 +0000 (15:30 -0700)
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!

mediagoblin/processing/__init__.py
mediagoblin/processing/task.py

index 02dba2f9919bcf8771662dc0fb4d9fb3809c8ab3..47f0b84e92abcc4e8d1d40383b5e8d62d0719259 100644 (file)
@@ -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
index 397514d0f719a9e69e2ba82bb86d0f363018a04d..d3770588dc6743273d7552d19cbe7ea8d2a2c557 100644 (file)
@@ -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