safe file directly to avoid django renaming

This commit is contained in:
j 2012-07-05 00:45:17 +02:00
parent 407bfb9eb6
commit 21f21e404e

View file

@ -75,7 +75,10 @@ class PosterCache(models.Model):
name = hashlib.sha1(url).hexdigest() name = hashlib.sha1(url).hexdigest()
try: try:
data = ox.net.readUrl(url) 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: except ox.net.urllib2.HTTPError, e:
#import traceback #import traceback
#print traceback.print_exc() #print traceback.print_exc()