mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
feat: wait 24h before deleting cdn images
This commit is contained in:
parent
31c0253b00
commit
f1de2f2858
3 changed files with 25 additions and 5 deletions
|
|
@ -54,13 +54,14 @@ struct CleanupJobEntry {
|
|||
async fn cleanup_job(pool: sqlx::PgPool, bucket: Arc<s3::Bucket>) -> anyhow::Result<()> {
|
||||
let mut tx = pool.begin().await?;
|
||||
|
||||
let image_id: Option<CleanupJobEntry> =
|
||||
sqlx::query_as(r#"
|
||||
let image_id: Option<CleanupJobEntry> = sqlx::query_as(
|
||||
r#"
|
||||
select id from image_cleanup_jobs
|
||||
where ts < now() - interval '1 day'
|
||||
for update skip locked limit 1;"#)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
for update skip locked limit 1;"#,
|
||||
)
|
||||
.fetch_optional(&mut *tx)
|
||||
.await?;
|
||||
if image_id.is_none() {
|
||||
info!("no job to run, sleeping for 1 minute");
|
||||
tokio::time::sleep(tokio::time::Duration::from_secs(60)).await;
|
||||
|
|
|
|||
|
|
@ -89,6 +89,8 @@ async fn pull(
|
|||
|
||||
if !req.force {
|
||||
if let Some(existing) = db::get_by_attachment_id(&state.pool, parsed.attachment_id).await? {
|
||||
// remove any pending image cleanup
|
||||
db::remove_deletion_queue(&state.pool, parsed.attachment_id).await?;
|
||||
return Ok(Json(PullResponse {
|
||||
url: existing.url,
|
||||
new: false,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue