From 034725d339b833bb0f0959c9a4b1641b7bf0ab3e Mon Sep 17 00:00:00 2001 From: Brian Pepple Date: Wed, 1 Aug 2018 10:13:50 -0400 Subject: [PATCH] Fix a potential bug where the image filename is to loarge for the db. * If the filename is greater than 132 characters let's not save it since it will cause a database error. Using 132 characters as the cut-off value since we need to take into account the 'upload_to' values of the Character & Publisher models. --- comics/utils/comicimporter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/comics/utils/comicimporter.py b/comics/utils/comicimporter.py index 1c0de7d..ca54ed2 100644 --- a/comics/utils/comicimporter.py +++ b/comics/utils/comicimporter.py @@ -476,7 +476,11 @@ def getDetailInfo(self, db_obj, fields, api_url): db_obj.year = data['year'] db_obj.cvurl = data['cvurl'] db_obj.desc = data['desc'] - db_obj.image = data['image'] + # If the image name from Comic Vine is too large, don't save it since it will + # cause a DB error. Using 132 as the value since that will take into account the + # upload_to value from the longest models (Characters & Pubishers). + if (len(data['image']) < 132): + db_obj.image = data['image'] db_obj.save() return True