diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-07-18 16:38:12 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-07-18 16:38:12 +0200 |
commit | 8b6fd105f67898a516b5e21cad566950e5dac99d (patch) | |
tree | 740b2d398f18f903566b8a00f5daef56f9d09e95 | |
parent | e79bc33a0a1c58c96d5c42e537df6eb1fad56fd9 (diff) |
Fixed breakage caused by using wrong hash.
-rwxr-xr-x | fbin.py | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -56,6 +56,15 @@ class Application(object): return user + def get_file(self, hash): + session = db.Session() + try: + return session.query(db.File).filter(db.File.hash == hash).one() + except db.NoResultFound: + return None + finally: + session.close() + def add_file(self, path, filename, file_hash, user = None): hash = ''.join(random.choice(base62_alphabet) for x in xrange(5)) new_path = os.path.join(settings.file_directory, hash + os.path.splitext(filename)[1]) @@ -122,7 +131,7 @@ class Application(object): hash = path[1] if '.' in hash: hash = hash.split('.')[0] - file = self.get_file_by_file_hash(hash) + file = self.get_file(hash) filename = file.get_path() if filename == None: start_response('404 Not Found', [('Content-Type', 'text/html')]) @@ -311,7 +320,7 @@ class Application(object): hash = path[1] thumbfile = os.path.join(settings.thumb_directory, hash + '.jpg') if not os.access(thumbfile, os.F_OK): - file = self.get_file_by_file_hash(hash) + file = self.get_file(hash) im = Image.open(file.get_path()) im.thumbnail(settings.thumb_size, Image.ANTIALIAS) im.save(thumbfile) |