From d9f61cf7d746b71c3e45e4d6a9836443002ebb86 Mon Sep 17 00:00:00 2001 From: Elrond Date: Wed, 3 Apr 2013 18:52:17 +0200 Subject: [PATCH] Create ProcessingState.store_public. The ideas is by Alon Levy. Use it in ProcessingState.copy_original for now. --- mediagoblin/processing/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index f9445e28..02462567 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -97,9 +97,17 @@ class ProcessingState(object): return queued_filename def copy_original(self, target_name, keyname=u"original"): + self.store_public(keyname, self.get_queued_filename(), target_name) + + def store_public(self, keyname, local_file, target_name=None): + if target_name is None: + target_name = os.path.basename(local_file) target_filepath = create_pub_filepath(self.entry, target_name) - mgg.public_store.copy_local_to_storage(self.get_queued_filename(), - target_filepath) + if keyname in self.entry.media_files: + _log.warn("store_public: keyname %r already used for file %r, " + "replacing with %r", keyname, + self.entry.media_files[keyname], target_filepath) + mgg.public_store.copy_local_to_storage(local_file, target_filepath) self.entry.media_files[keyname] = target_filepath def delete_queue_file(self): -- 2.25.1