Skip to content

Commit

Permalink
only add STIG library to DB after all STIGs are parsed
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstauffer committed Jul 28, 2019
1 parent 019b452 commit 3222519
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions backend/src/rmfdb/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,16 @@ def download_stigs(app, local_file, force):
library_file_hash_string))
library_result = StigLibrary.query.filter_by(
hash_value=library_file_hash_string).first()
if not library_result:
if library_result and not force:
flask.current_app.logger.info(
'This is a new STIG compilation library, '
'adding to database...')
library = StigLibrary(hash_value=library_file_hash_string)
db.session.add(library)
db.session.commit()
else:
if not force:
flask.current_app.logger.info(
'This is not a new STIG compilation library, exiting...')
return
'This is not a new STIG compilation library, exiting...')
return
flask.current_app.logger.info(
'This is a new STIG compilation library, adding to database...')
process_stig_zips(library_file_content)
library = StigLibrary(hash_value=library_file_hash_string)
db.session.add(library)
db.session.commit()


@main.command()
Expand Down

0 comments on commit 3222519

Please sign in to comment.