aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Spaeth <Sebastian@SSpaeth.de>2012-12-12 16:32:43 +0100
committerChristopher Allan Webber <cwebber@dustycloud.org>2013-01-22 14:05:54 -0600
commit36ae6bcbbb0fc3ab0dbbc8dcba0664b3d7c5096f (patch)
tree3a5551454bb0b1333e13e0160f82a26ad0d89cfc
parentb34d7e1d9b53f393aa673cc431a26bc640164c39 (diff)
downloadmediagoblin-36ae6bcbbb0fc3ab0dbbc8dcba0664b3d7c5096f.tar.lz
mediagoblin-36ae6bcbbb0fc3ab0dbbc8dcba0664b3d7c5096f.tar.xz
mediagoblin-36ae6bcbbb0fc3ab0dbbc8dcba0664b3d7c5096f.zip
Convert media processing backends to delete the queue directory (#254)
We never deleted our queue directory which were created per submission. With the FileStorage backend being able to delete directories now, we can request the deletion of the task directory too. It will only be deleted if it is completely empty.
-rw-r--r--mediagoblin/media_types/ascii/processing.py8
-rw-r--r--mediagoblin/media_types/audio/processing.py8
-rw-r--r--mediagoblin/media_types/image/processing.py8
-rw-r--r--mediagoblin/media_types/stl/processing.py8
-rw-r--r--mediagoblin/media_types/video/processing.py8
5 files changed, 33 insertions, 7 deletions
diff --git a/mediagoblin/media_types/ascii/processing.py b/mediagoblin/media_types/ascii/processing.py
index 254717eb..dbc9661e 100644
--- a/mediagoblin/media_types/ascii/processing.py
+++ b/mediagoblin/media_types/ascii/processing.py
@@ -127,8 +127,14 @@ def process_ascii(entry, workbench=None):
'ascii',
'xmlcharrefreplace'))
- mgg.queue_store.delete_file(queued_filepath)
+ # Remove queued media file from storage and database.
+ # queued_filepath is in the task_id directory which should
+ # be removed too, but fail if the directory is not empty to be on
+ # the super-safe side.
+ mgg.queue_store.delete_file(queued_filepath) # rm file
+ mgg.queue_store.delete_dir(queued_filepath[:-1]) # rm dir
entry.queued_media_file = []
+
media_files_dict = entry.setdefault('media_files', {})
media_files_dict['thumb'] = thumb_filepath
media_files_dict['unicode'] = unicode_filepath
diff --git a/mediagoblin/media_types/audio/processing.py b/mediagoblin/media_types/audio/processing.py
index e12cefe6..a89d6634 100644
--- a/mediagoblin/media_types/audio/processing.py
+++ b/mediagoblin/media_types/audio/processing.py
@@ -147,4 +147,10 @@ def process_audio(entry, workbench=None):
else:
entry.media_files['thumb'] = ['fake', 'thumb', 'path.jpg']
- mgg.queue_store.delete_file(queued_filepath)
+ # Remove queued media file from storage and database.
+ # queued_filepath is in the task_id directory which should
+ # be removed too, but fail if the directory is not empty to be on
+ # the super-safe side.
+ mgg.queue_store.delete_file(queued_filepath) # rm file
+ mgg.queue_store.delete_dir(queued_filepath[:-1]) # rm dir
+ entry.queued_media_file = []
diff --git a/mediagoblin/media_types/image/processing.py b/mediagoblin/media_types/image/processing.py
index e6a34ca0..2a5c463e 100644
--- a/mediagoblin/media_types/image/processing.py
+++ b/mediagoblin/media_types/image/processing.py
@@ -128,8 +128,12 @@ def process_image(entry, workbench=None):
entry, name_builder.fill('{basename}{ext}'))
mgg.public_store.copy_local_to_storage(queued_filename, original_filepath)
- # Remove queued media file from storage and database
- mgg.queue_store.delete_file(queued_filepath)
+ # Remove queued media file from storage and database.
+ # queued_filepath is in the task_id directory which should
+ # be removed too, but fail if the directory is not empty to be on
+ # the super-safe side.
+ mgg.queue_store.delete_file(queued_filepath) # rm file
+ mgg.queue_store.delete_dir(queued_filepath[:-1]) # rm dir
entry.queued_media_file = []
# Insert media file information into database
diff --git a/mediagoblin/media_types/stl/processing.py b/mediagoblin/media_types/stl/processing.py
index 3089f295..12b87317 100644
--- a/mediagoblin/media_types/stl/processing.py
+++ b/mediagoblin/media_types/stl/processing.py
@@ -164,8 +164,12 @@ def process_stl(entry, workbench=None):
with open(queued_filename, 'rb') as queued_file:
model_file.write(queued_file.read())
- # Remove queued media file from storage and database
- mgg.queue_store.delete_file(queued_filepath)
+ # Remove queued media file from storage and database.
+ # queued_filepath is in the task_id directory which should
+ # be removed too, but fail if the directory is not empty to be on
+ # the super-safe side.
+ mgg.queue_store.delete_file(queued_filepath) # rm file
+ mgg.queue_store.delete_dir(queued_filepath[:-1]) # rm dir
entry.queued_media_file = []
# Insert media file information into database
diff --git a/mediagoblin/media_types/video/processing.py b/mediagoblin/media_types/video/processing.py
index 4c9f0131..68d14148 100644
--- a/mediagoblin/media_types/video/processing.py
+++ b/mediagoblin/media_types/video/processing.py
@@ -121,4 +121,10 @@ def process_video(entry, workbench=None):
mgg.public_store.copy_local_to_storage(queued_filename, original_filepath)
entry.media_files['original'] = original_filepath
- mgg.queue_store.delete_file(queued_filepath)
+ # Remove queued media file from storage and database.
+ # queued_filepath is in the task_id directory which should
+ # be removed too, but fail if the directory is not empty to be on
+ # the super-safe side.
+ mgg.queue_store.delete_file(queued_filepath) # rm file
+ mgg.queue_store.delete_dir(queued_filepath[:-1]) # rm dir
+ entry.queued_media_file = []