Fix issues with backup importing (#2092)

* Closes #2087 
* Use `python manage.py import_ctf` instead of a new Process to import backups from the Admin Panel. 
    * This avoids a number of issues with gevent and webserver forking/threading models. 
* Add `--delete_import_on_finish` to `python manage.py import_ctf`
* Fix issue where `field_entries` table could not be imported when moving between MySQL and MariaDB
This commit is contained in:
Kevin Chung
2022-04-17 18:28:30 -04:00
committed by GitHub
parent 90e81d7298
commit 9ac0bbba6c
5 changed files with 89 additions and 17 deletions

View File

@@ -1,6 +1,8 @@
import datetime
import shutil
from pathlib import Path
from flask_migrate import MigrateCommand
from flask_script import Manager
@@ -71,10 +73,14 @@ def export_ctf(path=None):
@manager.command
def import_ctf(path):
def import_ctf(path, delete_import_on_finish=False):
with app.app_context():
import_ctf_util(path)
if delete_import_on_finish:
print(f"Deleting {path}")
Path(path).unlink()
if __name__ == "__main__":
manager.run()