From fb56676bf49de8e25487b938dc9a56f8440086f5 Mon Sep 17 00:00:00 2001 From: Rodney Ewing Date: Mon, 12 Aug 2013 11:55:00 -0700 Subject: [PATCH] delete existing file in store_public --- mediagoblin/processing/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mediagoblin/processing/__init__.py b/mediagoblin/processing/__init__.py index d5ec1fba..aadee78b 100644 --- a/mediagoblin/processing/__init__.py +++ b/mediagoblin/processing/__init__.py @@ -412,7 +412,8 @@ def get_orig_filename(entry, workbench): return orig_filename -def store_public(entry, keyname, local_file, target_name=None): +def store_public(entry, keyname, local_file, target_name=None, + delete_if_exists=True): if target_name is None: target_name = os.path.basename(local_file) target_filepath = create_pub_filepath(entry, target_name) @@ -420,6 +421,8 @@ def store_public(entry, keyname, local_file, target_name=None): _log.warn("store_public: keyname %r already used for file %r, " "replacing with %r", keyname, entry.media_files[keyname], target_filepath) + if delete_if_exists: + mgg.public_store.delete_file(entry.media_files[keyname]) mgg.public_store.copy_local_to_storage(local_file, target_filepath) entry.media_files[keyname] = target_filepath -- 2.25.1