diff --git a/apps/converter/api.py b/apps/converter/api.py index 4ee4adcd96..186007b7f7 100755 --- a/apps/converter/api.py +++ b/apps/converter/api.py @@ -115,7 +115,7 @@ def in_image_cache(input_filepath, size, page=0, format='jpg', quality=QUALITY_D return None -def convert(input_filepath, size, quality=QUALITY_DEFAULT, cache=True, page=0, format='jpg', extra_options='', mimetype=None, extension=None): +def convert(input_filepath, size, quality=QUALITY_DEFAULT, cache=True, page=0, format='jpg', extra_options='', mimetype=None, extension=None, cleanup=True): unoconv_output = None output_filepath = create_image_cache_filename(input_filepath, size=size, page=page, format=format, quality=quality, extra_options=extra_options) if os.path.exists(output_filepath): @@ -140,7 +140,8 @@ def convert(input_filepath, size, quality=QUALITY_DEFAULT, cache=True, page=0, f errors = get_errors(error_string) raise ConvertError(status, errors) finally: - cleanup(input_filepath) + if cleanup: + cleanup(input_filepath) if unoconv_output: cleanup(unoconv_output) return output_filepath diff --git a/apps/documents/views.py b/apps/documents/views.py index a01a40a3d6..738b8cba11 100755 --- a/apps/documents/views.py +++ b/apps/documents/views.py @@ -521,7 +521,7 @@ def document_download(request, document_id): def staging_file_preview(request, staging_file_id): try: filepath = StagingFile.get(staging_file_id).filepath - output_file = convert(filepath, STAGING_FILES_PREVIEW_SIZE) + output_file = convert(filepath, STAGING_FILES_PREVIEW_SIZE, cleanup=False) return serve_file(request, File(file=open(output_file, 'r'))) except Exception, e: return serve_file(request, File(file=open('%simages/1297211435_error.png' % settings.MEDIA_ROOT, 'r')))