ba6fe0f
use export::http::{Path, State};
use export::rest::{AppResponseData, NoData};
use token::Session;
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>,
session: Session,
Path(path): Path<RepoPath>,
) -> Result<AppResponseData<NoData>, ApiError> {
require_writer(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
service
.pack_repack(path.space_name, path.repo_name)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(NoData))
}