More lints
This commit is contained in:
parent
1e1dd7b877
commit
2d5c91a5ef
7 changed files with 27 additions and 20 deletions
|
|
@ -26,7 +26,6 @@ pub enum SyncServerError {
|
|||
#[error("Unauthorized: {0}")]
|
||||
Unauthorized(#[source] anyhow::Error),
|
||||
|
||||
#[expect(dead_code)]
|
||||
#[error("Permission denied error: {0}")]
|
||||
PermissionDeniedError(#[source] anyhow::Error),
|
||||
}
|
||||
|
|
@ -107,6 +106,7 @@ pub fn unauthorized_error(error: anyhow::Error) -> SyncServerError {
|
|||
SyncServerError::Unauthorized(error)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn permission_denied_error(error: anyhow::Error) -> SyncServerError {
|
||||
info!("Permission denied error: {:?}", error);
|
||||
SyncServerError::PermissionDeniedError(error)
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ pub async fn create_server(app_state: AppState) -> Result<()> {
|
|||
))
|
||||
.layer(
|
||||
CorsLayer::new()
|
||||
.allow_origin("*".parse::<HeaderValue>().unwrap())
|
||||
.allow_origin("*".parse::<HeaderValue>().expect("Failed to parse origin"))
|
||||
.allow_headers([http::header::CONTENT_TYPE, http::header::AUTHORIZATION])
|
||||
.allow_methods([Method::GET, Method::POST, Method::PUT, Method::DELETE]),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -44,13 +44,15 @@ pub async fn update_document(
|
|||
.get_document_version(&vault_id, request.parent_version_id, None)
|
||||
.await
|
||||
.map_err(server_error)?
|
||||
.map(Ok)
|
||||
.unwrap_or_else(|| {
|
||||
Err(not_found_error(anyhow!(
|
||||
"Parent version with id `{}` not found",
|
||||
request.parent_version_id
|
||||
)))
|
||||
})?;
|
||||
.map_or_else(
|
||||
|| {
|
||||
Err(not_found_error(anyhow!(
|
||||
"Parent version with id `{}` not found",
|
||||
request.parent_version_id
|
||||
)))
|
||||
},
|
||||
Ok,
|
||||
)?;
|
||||
|
||||
let mut transaction = state
|
||||
.database
|
||||
|
|
@ -69,12 +71,14 @@ pub async fn update_document(
|
|||
.get_latest_document(&vault_id, &document_id, Some(&mut transaction))
|
||||
.await
|
||||
.map_err(server_error)?
|
||||
.map(Ok)
|
||||
.unwrap_or_else(|| {
|
||||
Err(not_found_error(anyhow!(
|
||||
"Document with id `{document_id}` not found",
|
||||
)))
|
||||
})?;
|
||||
.map_or_else(
|
||||
|| {
|
||||
Err(not_found_error(anyhow!(
|
||||
"Document with id `{document_id}` not found",
|
||||
)))
|
||||
},
|
||||
Ok,
|
||||
)?;
|
||||
|
||||
let content_bytes = base64_to_bytes(&request.content_base64)
|
||||
.context("Failed to decode base64 content in request")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue