From b08f6c52a7c2467edd8c8a256a55dc78c51acabf Mon Sep 17 00:00:00 2001 From: Bryan Date: Tue, 4 Feb 2014 01:16:20 -0500 Subject: [PATCH] upstream modifications obviate the need for this hack --- karmaworld/apps/notes/models.py | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/karmaworld/apps/notes/models.py b/karmaworld/apps/notes/models.py index 5cc5097..cb6c039 100644 --- a/karmaworld/apps/notes/models.py +++ b/karmaworld/apps/notes/models.py @@ -146,23 +146,7 @@ class Document(models.Model): """ Downloads the file from filepicker.io and returns a Django File wrapper object """ fpf = django_filepicker.utils.FilepickerFile(self.fp_file.name) - fd = fpf.get_file(self.fp_file.field.additional_params) - # temporary workaround. FilepickerFile closes/deletes the fd when - # garbage collected, so write it to another fd. - # https://github.com/Ink/django-filepicker/issues/25 - newfd = os.tmpfile() - buff_size = 1048576 # read 1 MiB at a time - buff = fd.read(buff_size) - while buff != '': - # write until EOF - newfd.write(buff) - buff = fd.read(buff_size) - # replace the Django File's python file with the reset temp file. - newfd.seek(0) - fd.file = newfd - # force FilepickerFile to be garbage collected now, why not - del fpf - return fd + return fpf.get_file(self.fp_file.field.additional_params) def save(self, *args, **kwargs): if self.name and not self.slug: -- 2.25.1