f934c68
use ::session::AuthedUser;
use api::http::{Path, State};
use api::rest::{AppResponseData, NoData};
use crate::errors::{ApiError, GitApiError};
use crate::handler::{RepoPath, require_writer};
use crate::service::GitService;
#[utoipa::path(
post,
path = "/repos/{space_name}/{repo_name}/packs/repack",
tag = "packs",
description = "对仓库执行全量重打包并删除冗余 pack。",
params(RepoPath),
responses(
(status = 200, description = "repack repository", body = AppResponseData<NoData>)
)
)]
pub async fn repack(
State(service): State<GitService>,
AuthedUser(uid): AuthedUser,
Path(path): Path<RepoPath>,
) -> Result<AppResponseData<NoData>, ApiError> {
let (ctx, _) = require_writer(
&service,
uid,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
service.pack_repack(&ctx).await.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(NoData))
}