Skip to content

Commit

Permalink
Merge pull request #133 from ael-code/to_fsdb_0.3
Browse files Browse the repository at this point in the history
upgrade to fsdb v0.3.2
  • Loading branch information
leophys committed Apr 17, 2015
2 parents 8a94042 + 5c22d81 commit 7215ecc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def read(fname):
'flask-script',
'Flask',
'opensearch',
'Fsdb==0.2.5'
'Fsdb'
],
package_data = {
# If any package contains *.mo include them:
Expand Down
11 changes: 6 additions & 5 deletions webant/webant.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from presets import PresetManager
from constants import isoLangs
from fsdb import Fsdb
from fsdb.hashtools import calc_file_digest

from libreantdb import DB
from agherant import agherant
Expand Down Expand Up @@ -145,18 +146,18 @@ def upload():

files = []
for upName,upFile in request.files.items():
tmpFile, tmpFilePath = tempfile.mkstemp()
tmpFileFd, tmpFilePath = tempfile.mkstemp()
upFile.save(tmpFilePath)
fileInfo = {}
fileInfo['name'] = secure_filename(upFile.filename)
fileInfo['size'] = os.path.getsize(tmpFilePath)
fileInfo['mime'] = upFile.mimetype
fileInfo['notes'] = request.form[upName+'_notes']
fileInfo['sha1'] = Fsdb.fileDigest(tmpFilePath, algorithm="sha1")
fileInfo['sha1'] = calc_file_digest(tmpFilePath, algorithm="sha1")
fileInfo['download_count'] = 0
fsdb_id = app.fsdb.add(tmpFilePath)
# close and delete tmpFile
os.close(tmpFile)
# close and delete tmpFileFd
os.close(tmpFileFd)
os.remove(tmpFilePath)

fileInfo['fsdb_id'] = fsdb_id
Expand Down Expand Up @@ -213,7 +214,7 @@ def download_book(bookid, fileid):
except:
app.logger.warn("Cannot increment download count",
exc_info=1)
return send_file(app.fsdb.getFilePath(file['fsdb_id']),
return send_file(app.fsdb.get_file_path(file['fsdb_id']),
mimetype=file['mime'],
attachment_filename=file['name'],
as_attachment=True)
Expand Down

0 comments on commit 7215ecc

Please sign in to comment.