Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/meta/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ reqwest = { workspace = true }
snafu = { workspace = true }
sqlx = { workspace = true }
omniqueue = { workspace = true }
futures = { workspace = true }

[dev-dependencies]
tempfile = { workspace = true }
Expand Down
23 changes: 23 additions & 0 deletions crates/meta/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use axum::{
response::IntoResponse,
};
use chrono::Utc;
use futures::TryStreamExt;
use object_store::ObjectStoreExt;
use serde::{Deserialize, Serialize};
use snafu::ResultExt;
use stream_core::{
Expand Down Expand Up @@ -203,6 +205,27 @@ pub async fn delete_video(
// Non-fatal -- deletion proceeds even if event publishing fails.
}

// Best-effort cleanup of stored objects (raw uploads + HLS segments).
// Errors are logged but do not block deletion — DB consistency is more
// important than leftover storage objects.
for prefix in ["raw", "hls"] {
let path = object_store::path::Path::from(format!("{prefix}/{video_id}/").as_str());
let objects: Vec<_> = state
.store
.list(Some(&path))
.try_collect()
.await
.unwrap_or_default();
for obj in &objects {
if let Err(e) = state.store.delete(&obj.location).await {
tracing::warn!(
path = %obj.location,
"failed to delete storage object: {e}"
);
}
}
}

// Delete processing tasks to satisfy FK constraints.
task_repo::delete_for_video(&state.db, &video_id)
.await
Expand Down