[Setup] Fix data deletion. (#3384)

* I'm ready to 🔪 some of these entrypoints

* If we're gonna teardown here, may as well do it right
This commit is contained in:
Michael H 2020-01-16 19:09:09 -05:00 committed by jack1142
parent d6d14617d2
commit 85438e7454

View File

@ -253,20 +253,23 @@ async def remove_instance(
backend = get_current_backend(instance) backend = get_current_backend(instance)
driver_cls = drivers.get_driver_class(backend) driver_cls = drivers.get_driver_class(backend)
await driver_cls.initialize(**data_manager.storage_details())
try:
if delete_data is True:
await driver_cls.delete_all_data(interactive=interactive, drop_db=drop_db)
if delete_data is True: if interactive is True and remove_datapath is None:
await driver_cls.delete_all_data(interactive=interactive, drop_db=drop_db) remove_datapath = click.confirm(
"Would you like to delete the instance's entire datapath?", default=False
)
if interactive is True and remove_datapath is None: if remove_datapath is True:
remove_datapath = click.confirm( data_path = data_manager.core_data_path().parent
"Would you like to delete the instance's entire datapath?", default=False safe_delete(data_path)
)
if remove_datapath is True: save_config(instance, {}, remove=True)
data_path = data_manager.core_data_path().parent finally:
safe_delete(data_path) await driver_cls.teardown()
save_config(instance, {}, remove=True)
print("The instance {} has been removed\n".format(instance)) print("The instance {} has been removed\n".format(instance))