don't stall on super big pdf files

pull/94/head
eric 2019-03-25 12:47:04 -04:00
parent 2396e23ae4
commit fe05ff9f88
1 changed files with 8 additions and 2 deletions

View File

@ -158,8 +158,14 @@ def make_harvested_ebook(content, ebook, format, filesize=0):
format=format,
source=ebook.url,
)
try:
new_ebf.file.save(path_for_file(new_ebf, None), ContentFile(content))
new_ebf.save()
except MemoryError: #huge pdf files cause problems here
logger.error("memory error saving ebook file for %s", ebook.url)
new_ebf.delete()
return None, False
new_ebook = Ebook.objects.create(
edition=ebook.edition,
format=format,