show error message for invalid tweet archive

This commit is contained in:
codl 2017-08-07 15:35:15 +02:00
parent a6678f1057
commit 7d4e9945a5
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
2 changed files with 14 additions and 2 deletions

View File

@ -6,6 +6,7 @@ from lib import require_auth
from model import Account, Session, Post, TwitterArchive
from app import app, db, sentry
import tasks
from zipfile import BadZipFile
@app.before_request
def load_viewer():
@ -68,9 +69,14 @@ def upload_tweet_archive():
db.session.add(ta)
db.session.commit()
tasks.chunk_twitter_archive(ta.id)
try:
tasks.chunk_twitter_archive(ta.id)
return redirect(url_for('index', _anchor='recent_archives'))
assert ta.chunks > 0
return redirect(url_for('index', _anchor='recent_archives'))
except (BadZipFile, AssertionError):
return redirect(url_for('index', error='The file you uploaded is not a valid tweet archive. No posts have been imported.'))
@app.route('/settings', methods=('POST',))
@require_auth

View File

@ -2,6 +2,12 @@
{% extends 'lib/layout.html' %}
{% block body -%}
{% if error %}
<section class=banners>
<div class="banner error">{{ error|safe }}</div>
</section>
{% endif %}
<section class=viewer>
<p>Hello,
<img class=avatar src="{{g.viewer.account.avatar_url}}"/>