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

feat: delete_msgs: Use transaction() instead of call_write() #6363

Merged
merged 1 commit into from
Dec 24, 2024

Conversation

iequidoo
Copy link
Collaborator

@iequidoo iequidoo commented Dec 23, 2024

Explicit transaction does the only commit (and fsync()).
Checked other usages of call_write(), it seems in other places it doesn't make sense or isn't possible to use transaction().

@@ -707,9 +707,6 @@ pub(crate) async fn save(
))?;

if timestamp > newest_timestamp {
// okay to drop, as we use cached prepared statements
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

These are auto-dropped at the end of the scope anyway

@iequidoo iequidoo marked this pull request as ready for review December 23, 2024 17:16
@iequidoo iequidoo requested a review from link2xt December 23, 2024 17:16
src/message.rs Outdated
@@ -1613,15 +1613,15 @@ pub async fn delete_msgs(context: &Context, msg_ids: &[MsgId]) -> Result<()> {
modified_chat_ids.insert(msg.chat_id);

let target = context.get_delete_msgs_target().await?;
let update_db = |conn: &mut rusqlite::Connection| {
let update_db = |conn: &mut rusqlite::Transaction| {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd rename conn to transaction.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Transaction implements Deref<Target = Connection>, so maybe conn is also ok, but renamed it to trans

Explicit transaction does the only commit (and fsync()).
@iequidoo iequidoo force-pushed the iequidoo/use-transaction branch from 4cc796b to 0efd7cd Compare December 24, 2024 01:02
@iequidoo iequidoo merged commit a910808 into main Dec 24, 2024
24 checks passed
@iequidoo iequidoo deleted the iequidoo/use-transaction branch December 24, 2024 01:02
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.

2 participants