mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-17 05:54:19 +01:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user