Only initialize and teardown driver if actually needed #5313
No reviewers
Labels
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Mrcoolgamer11/Red-DiscordBot!5313
Loading…
Reference in a new issue
No description provided.
Delete branch "V3/develop"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description of the changes
Check if delete_data is True before initializing or tearing down driver.
Closes #5312.
I think it would be a great idea to let the user know that he should select "No" in case he didn't created the database, otherwise it could be confusing of why it throw an error and doesn't try again with the "No" option. 🤷
@ -248,39 +248,41 @@ async def remove_instance(remove_datapath: Optional[bool] = None,):data_manager.load_basic_configuration(instance)backend = get_current_backend(instance)This should only be shown when a non-JSON backend is used. Also, you should just say that the removal of instance's data requires the database server to be running as what you currently put is not the only case this can happen.
@ -261,1 +261,4 @@if backend != BackendType.JSON:msg += " The database server must be running for this to work."_create_backup = click.confirm(msg, default=False)It would be better if all of this were under a single
ifstatement along withtry/finallyclause:@ -261,1 +261,4 @@if backend != BackendType.JSON:msg += " The database server must be running for this to work."_create_backup = click.confirm(msg, default=False)done
@ -248,39 +248,41 @@ async def remove_instance(remove_datapath: Optional[bool] = None,):data_manager.load_basic_configuration(instance)backend = get_current_backend(instance)Not sure how to check which backend is in use, would I get it from this?
Line 176
default_dirs["STORAGE_TYPE"] = storage_type.value@ -248,39 +248,41 @@ async def remove_instance(remove_datapath: Optional[bool] = None,):data_manager.load_basic_configuration(instance)backend = get_current_backend(instance)There's a
backend = get_current_backend(instance)line a bit below, just move it a bit higher and then you can check it withif backend != BackendType.JSON@ -248,39 +248,41 @@ async def remove_instance(remove_datapath: Optional[bool] = None,):data_manager.load_basic_configuration(instance)backend = get_current_backend(instance)I think I did that right - it's still failing style though. Not sure why
Note: the issues with the Black style should generally be fixed with the Black auto-formatter per our contributing guidelines but in this case, it should be enough to just accept my code suggestions.
@ -248,39 +248,41 @@ async def remove_instance(remove_datapath: Optional[bool] = None,There is no need to mention not having the database server, it should be clear enough with just the first part and otherwise, it is also quite long.
Also, this code suggestion fixes issues with the black style.
@ -263,4 +266,3 @@await create_backup(instance)backend = get_current_backend(instance)driver_cls = drivers.get_driver_class(backend)This and the following lines should not be part of the
if delete_date is TrueblockThe code can't have trailing whitespace:
I think everything is fixed - sorry about all the issues. I probably shouldn't have tried to do this.
Don't worry, it's your first PR, it can't be perfect :)
It seems all good to me now, I'll test it out later and merge if I don't see any issues with this approach, thanks!
Looks good to me, thanks for the PR!
Thanks L33Tech for the PR 🎉. I'm working now to backport this PR to: 3.4.
#5333 is a backport of this pull request to Red 3.4.