use axum::extract::{Path, State}; use export::rest::AppResponseData; use jwt::Session; use crate::errors::{ApiError, GitApiError}; use crate::handler::{RepoPath, require_writer}; use crate::service::GitService; #[derive(Debug, Clone, serde::Serialize, utoipa::ToSchema)] pub struct LfsCleanupResponse { pub removed: i64, } #[utoipa::path( post, path = "/repos/{space_name}/{repo_name}/lfs/cleanup", tag = "lfs", description = "清理 LFS 数据库中失引用记录与存储中的未引用对象。", params(RepoPath), responses( (status = 200, description = "cleanup unreferenced lfs objects", body = AppResponseData) ) )] pub async fn cleanup_unreferenced( State(service): State, session: Session, Path(path): Path, ) -> Result, ApiError> { require_writer( &service, &session, path.space_name.clone(), path.repo_name.clone(), ) .await?; let removed = service .lfs_cleanup_unreferenced(path.space_name, path.repo_name) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(LfsCleanupResponse { removed })) }