diff --git a/mayan/apps/sources/classes.py b/mayan/apps/sources/classes.py index e7700cf3d6..412c28970b 100644 --- a/mayan/apps/sources/classes.py +++ b/mayan/apps/sources/classes.py @@ -10,7 +10,9 @@ from django.core.files import File from django.core.files.storage import FileSystemStorage from django.utils.encoding import smart_str from django.utils.translation import ugettext +from django.utils.translation import ugettext_lazy as _ +from common.utils import fs_cleanup from converter.api import convert, cache_cleanup from converter.literals import (DEFAULT_ZOOM_LEVEL, DEFAULT_ROTATION, DEFAULT_PAGE_NUMBER, DEFAULT_FILE_FORMAT_MIMETYPE) @@ -43,8 +45,8 @@ class StagingFile(object): return os.path.join(self.staging_folder.folder_path, self.filename) def get_image(self, size, page, zoom, rotation, as_base64=True): - #return self.get_valid_image(size=size, transformations=transformations) - converted_file_path = convert(self.get_full_path(), size=size)#, cleanup_files=True)#, transformations=transformations) + # TODO: add support for transformations + converted_file_path = convert(self.get_full_path(), size=size) if as_base64: mimetype = get_mimetype(open(converted_file_path, 'r'), converted_file_path, mimetype_only=True)[0] @@ -55,12 +57,5 @@ class StagingFile(object): else: return file_path - #def delete(self, preview_size, transformations): - # cache_cleanup(self.filepath, size=preview_size, transformations=transformations) - # try: - # os.unlink(self.filepath) - # except OSError, exc: - # if exc.errno == errno.ENOENT: - # pass - # else: - # raise Exception(ugettext(u'Unable to delete staging file: %s') % exc) + def delete(self): + os.unlink(self.get_full_path())