From 21f21e404e648cf14e88d4d795128e362adcf847 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 5 Jul 2012 00:45:17 +0200 Subject: [PATCH] safe file directly to avoid django renaming --- oxdata/poster/models.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/oxdata/poster/models.py b/oxdata/poster/models.py index 5439c14..56dcdff 100644 --- a/oxdata/poster/models.py +++ b/oxdata/poster/models.py @@ -75,7 +75,10 @@ class PosterCache(models.Model): name = hashlib.sha1(url).hexdigest() try: data = ox.net.readUrl(url) - self.image.save(name, ContentFile(data)) + self.image.name = poster.models.poster_path(self.url, 'image.jpg') + with open(self.image.path, 'w') as f: + f.write(data) + self.save() except ox.net.urllib2.HTTPError, e: #import traceback #print traceback.print_exc()