Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions securedrop/journalist_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,16 @@ def col_download_all(cols_selected: List[str]) -> werkzeug.Response:
def serve_file_with_etag(db_obj: Union[Reply, Submission]) -> flask.Response:
file_path = Storage.get_default().path(db_obj.source.filesystem_id, db_obj.filename)
add_range_headers = not current_app.config["USE_X_SENDFILE"]
response = send_file(
file_path,
mimetype="application/pgp-encrypted",
as_attachment=True,
etag=False,
conditional=add_range_headers,
) # Disable Flask default ETag
try:
response = send_file(
file_path,
mimetype="application/pgp-encrypted",
as_attachment=True,
etag=False,
conditional=add_range_headers,
) # Disable Flask default ETag
except FileNotFoundError:
abort(404)

if not db_obj.checksum:
add_checksum_for_file(db.session, db_obj, file_path)
Expand Down