Skip to content
Clone
b7cd2b1
46 lines 1.3 KB Rust
use export::http::{Path, Query, State};
use export::rest::{AppResponseData, NoData};
use jwt::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::{RepoPath, lfs};
use crate::service::GitService;
#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
pub struct LfsUnlockPathQuery {
pub path: String,
#[serde(default)]
pub force: Option<bool>,
}
#[utoipa::path(
delete,
path = "/repos/{space_name}/{repo_name}/lfs/locks",
tag = "lfs",
description = "按路径释放 LFS 文件锁;管理员可用 force 越权释放。",
params(RepoPath, LfsUnlockPathQuery),
responses(
(status = 200, description = "remove lfs lock by path", body = AppResponseData<NoData>)
)
)]
pub async fn unlock(
State(service): State<GitService>,
session: Session,
Path(path): Path<RepoPath>,
Query(q): Query<LfsUnlockPathQuery>,
) -> Result<AppResponseData<NoData>, ApiError> {
let force = q.force.unwrap_or(false);
let uid = lfs::unlock_actor(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
force,
)
.await?;
service
.lfs_unlock(path.space_name, path.repo_name, uid, q.path, force)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(NoData))
}