1
+ import os
1
2
from io import BytesIO
2
3
import subprocess # nosec
3
4
from datetime import datetime , timezone
@@ -619,8 +620,8 @@ def journeyEdit(): # noqa: C901
619
620
return render_template ('database/journey_edit.html' , current_app = current_app , form = form )
620
621
621
622
622
- @bp .route ('/backup' , methods = ['GET' , 'POST' ])
623
- def backup ():
623
+ @bp .route ('/backup' , methods = ['GET' , 'POST' ]) # noqa: C901
624
+ def backup (): # noqa: C901
624
625
form = BackupRestoreForm ()
625
626
626
627
if form .restore .data and form .validate_on_submit ():
@@ -633,9 +634,11 @@ def backup():
633
634
if file .filename == '' :
634
635
flash ('No selected file' )
635
636
elif file and file .filename .endswith ('.vwsfrienddbbackup' ):
636
- if current_app .configDir is None :
637
- flash ('Config directory is not configured' )
637
+ if current_app .configDir is None or not os . path . isdir ( current_app . configDir ) :
638
+ flash ('Config directory is not configured or does not exist ' )
638
639
else :
640
+ if not os .path .isdir (current_app .configDir + '/provisioning' ):
641
+ os .makedirs (current_app .configDir + '/provisioning' )
639
642
form .file .data .save (current_app .configDir + '/provisioning/database.vwsfrienddbbackup' )
640
643
flash ('backup was uploaded, now restarting to apply the backup' )
641
644
return redirect (url_for ('restart' ))
0 commit comments