Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SQL App Group Crash #339

Merged
merged 3 commits into from
May 24, 2024
Merged

Fix SQL App Group Crash #339

merged 3 commits into from
May 24, 2024

Conversation

nplasterer
Copy link
Contributor

Should close #336

This adds two new functions that should be called on background and foreground of the app when using app groups with the local database to disconnect and reconnect the database to avoid crashing.

@nplasterer nplasterer self-assigned this May 23, 2024
@nplasterer nplasterer requested a review from a team as a code owner May 23, 2024 23:19
@@ -462,6 +462,21 @@ public final class Client {
let fm = FileManager.default
try fm.removeItem(atPath: dbPath)
}

@available(*, deprecated, message: "This function is delicate and should be used with caution. App will error if database not properly reconnected. See: reconnectLocalDatabase()")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@insipx was able to mark this function as delicate to warn developers before using.

try client.releaseDbConnection()
}

public func reconnectLocalDatabase() async throws {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be any reason to mark this as delicate because if they try to reconnect a already connected database nothing bad should happen right?

@nplasterer nplasterer merged commit 46afeef into main May 24, 2024
2 of 4 checks passed
@nplasterer nplasterer deleted the np/fix-sql-db-bug branch May 24, 2024 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQlite & iOS Crashes
2 participants