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.
This commit is contained in:
Sebastian Spaeth 2012-12-12 16:32:43 +01:00 committed by Christopher Allan Webber
parent b34d7e1d9b
commit 36ae6bcbbb
5 changed files with 33 additions and 7 deletions

View File

@ -127,8 +127,14 @@ def process_ascii(entry, workbench=None):
'ascii', 'ascii',
'xmlcharrefreplace')) '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 = [] entry.queued_media_file = []
media_files_dict = entry.setdefault('media_files', {}) media_files_dict = entry.setdefault('media_files', {})
media_files_dict['thumb'] = thumb_filepath media_files_dict['thumb'] = thumb_filepath
media_files_dict['unicode'] = unicode_filepath media_files_dict['unicode'] = unicode_filepath

View File

@ -147,4 +147,10 @@ def process_audio(entry, workbench=None):
else: else:
entry.media_files['thumb'] = ['fake', 'thumb', 'path.jpg'] 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 = []

View File

@ -128,8 +128,12 @@ def process_image(entry, workbench=None):
entry, name_builder.fill('{basename}{ext}')) entry, name_builder.fill('{basename}{ext}'))
mgg.public_store.copy_local_to_storage(queued_filename, original_filepath) mgg.public_store.copy_local_to_storage(queued_filename, original_filepath)
# Remove queued media file from storage and database # Remove queued media file from storage and database.
mgg.queue_store.delete_file(queued_filepath) # 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 = [] entry.queued_media_file = []
# Insert media file information into database # Insert media file information into database

View File

@ -164,8 +164,12 @@ def process_stl(entry, workbench=None):
with open(queued_filename, 'rb') as queued_file: with open(queued_filename, 'rb') as queued_file:
model_file.write(queued_file.read()) model_file.write(queued_file.read())
# Remove queued media file from storage and database # Remove queued media file from storage and database.
mgg.queue_store.delete_file(queued_filepath) # 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 = [] entry.queued_media_file = []
# Insert media file information into database # Insert media file information into database

View File

@ -121,4 +121,10 @@ def process_video(entry, workbench=None):
mgg.public_store.copy_local_to_storage(queued_filename, original_filepath) mgg.public_store.copy_local_to_storage(queued_filename, original_filepath)
entry.media_files['original'] = 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 = []