From 5a5c47ecbc72fe0bc19008a081a1d2c5f5c66bff Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 15 Jul 2024 23:58:50 +0200 Subject: [PATCH] fix: oops forgot to commit but also no need for tx in case of failures mid-way, this allows restarting it multiple times and still succeeding --- upub/cli/src/cloak.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/upub/cli/src/cloak.rs b/upub/cli/src/cloak.rs index 463a07f..ebcff9f 100644 --- a/upub/cli/src/cloak.rs +++ b/upub/cli/src/cloak.rs @@ -3,8 +3,6 @@ use sea_orm::{ActiveModelTrait, ActiveValue::{Set, Unchanged}, ColumnTrait, Enti use upub::traits::{fetch::RequestError, Cloaker}; pub async fn cloak(ctx: upub::Context, post_contents: bool) -> Result<(), RequestError> { - let tx = ctx.db().begin().await?; - { let mut stream = upub::model::attachment::Entity::find() .filter(upub::model::attachment::Column::Url.not_like(format!("{}%", ctx.base()))) @@ -16,7 +14,7 @@ pub async fn cloak(ctx: upub::Context, post_contents: bool) -> Result<(), Reques let (sig, url) = ctx.cloak(&attachment.url); let mut model = attachment.into_active_model(); model.url = Set(upub::url!(ctx, "/proxy/{sig}/{url}")); - model.update(&tx).await?; + model.update(ctx.db()).await?; } } @@ -39,7 +37,7 @@ pub async fn cloak(ctx: upub::Context, post_contents: bool) -> Result<(), Reques content: Set(Some(sanitized)), ..Default::default() }; - model.update(&tx).await?; + model.update(ctx.db()).await?; } } }