Skip to content

Commit

Permalink
create provisioning directory if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
tillsteinbach committed Oct 22, 2021
1 parent 1ef5e57 commit 2611125
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions vwsfriend/vwsfriend/ui/database.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
from io import BytesIO
import subprocess # nosec
from datetime import datetime, timezone
Expand Down Expand Up @@ -619,8 +620,8 @@ def journeyEdit(): # noqa: C901
return render_template('database/journey_edit.html', current_app=current_app, form=form)


@bp.route('/backup', methods=['GET', 'POST'])
def backup():
@bp.route('/backup', methods=['GET', 'POST']) # noqa: C901
def backup(): # noqa: C901
form = BackupRestoreForm()

if form.restore.data and form.validate_on_submit():
Expand All @@ -633,9 +634,11 @@ def backup():
if file.filename == '':
flash('No selected file')
elif file and file.filename.endswith('.vwsfrienddbbackup'):
if current_app.configDir is None:
flash('Config directory is not configured')
if current_app.configDir is None or not os.path.isdir(current_app.configDir):
flash('Config directory is not configured or does not exist')
else:
if not os.path.isdir(current_app.configDir + '/provisioning'):
os.makedirs(current_app.configDir + '/provisioning')
form.file.data.save(current_app.configDir + '/provisioning/database.vwsfrienddbbackup')
flash('backup was uploaded, now restarting to apply the backup')
return redirect(url_for('restart'))
Expand Down

0 comments on commit 2611125

Please sign in to comment.