Commit e4d3ecbc authored by contabo-server's avatar contabo-server
Browse files

fixed filename

parent e9c41d4e
......@@ -52,8 +52,8 @@ class Attachment(db.Model):
def __init__(self, share_id, file):
self.share_id = share_id
self.filename = file.filename
fn = secure_filename(filename=file.filename)
self.filename = fn
# save file
from werkzeug.utils import secure_filename
fn = secure_filename(filename=file.filename)
file.save(os.path.join(current_app.config['MEDIA_LOCATION'], share_id, fn))
......@@ -14,7 +14,7 @@ def get_and_check_share(share_id) -> Share:
share = Share.query.get(share_id)
if share is None:
return None
if share.download_limit <= 0 or datetime.now() > share.expires:
if share.download_limit <= 0 or (share.expires is not None and datetime.now() > share.expires):
que.enqueue(delete_share, share.id)
return None
return share
......@@ -120,9 +120,9 @@ def media(share_id, filename):
if share.password:
if share_id not in session:
return redirect(url_for('share_auth', share_id=share_id))
share.download_limit -= 1
db.session.commit()
return send_from_directory(os.path.join(current_app.config['MEDIA_LOCATION'], share.id),
filename=filename, as_attachment=True)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment