pinakes-server: propagate sync/share errors; cap unbounded pagination
limits Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I79339740dd34353014d02f571b6f55a26a6a6964
This commit is contained in:
parent
b12ad5d272
commit
f049dd100a
3 changed files with 37 additions and 15 deletions
|
|
@ -862,7 +862,9 @@ pub async fn rename_media(
|
|||
changed_by_device: None,
|
||||
timestamp: chrono::Utc::now(),
|
||||
};
|
||||
let _ = state.storage.record_sync_change(&change).await;
|
||||
if let Err(e) = state.storage.record_sync_change(&change).await {
|
||||
tracing::warn!(error = %e, "failed to record sync change");
|
||||
}
|
||||
|
||||
// Record audit
|
||||
pinakes_core::audit::record_action(
|
||||
|
|
@ -902,7 +904,9 @@ pub async fn move_media_endpoint(
|
|||
changed_by_device: None,
|
||||
timestamp: chrono::Utc::now(),
|
||||
};
|
||||
let _ = state.storage.record_sync_change(&change).await;
|
||||
if let Err(e) = state.storage.record_sync_change(&change).await {
|
||||
tracing::warn!(error = %e, "failed to record sync change");
|
||||
}
|
||||
|
||||
// Record audit
|
||||
pinakes_core::audit::record_action(
|
||||
|
|
@ -958,7 +962,9 @@ pub async fn batch_move_media(
|
|||
changed_by_device: None,
|
||||
timestamp: chrono::Utc::now(),
|
||||
};
|
||||
let _ = state.storage.record_sync_change(&change).await;
|
||||
if let Err(e) = state.storage.record_sync_change(&change).await {
|
||||
tracing::warn!(error = %e, "failed to record sync change");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1001,7 +1007,9 @@ pub async fn soft_delete_media(
|
|||
changed_by_device: None,
|
||||
timestamp: chrono::Utc::now(),
|
||||
};
|
||||
let _ = state.storage.record_sync_change(&change).await;
|
||||
if let Err(e) = state.storage.record_sync_change(&change).await {
|
||||
tracing::warn!(error = %e, "failed to record sync change");
|
||||
}
|
||||
|
||||
// Record audit
|
||||
pinakes_core::audit::record_action(
|
||||
|
|
@ -1040,7 +1048,9 @@ pub async fn restore_media(
|
|||
changed_by_device: None,
|
||||
timestamp: chrono::Utc::now(),
|
||||
};
|
||||
let _ = state.storage.record_sync_change(&change).await;
|
||||
if let Err(e) = state.storage.record_sync_change(&change).await {
|
||||
tracing::warn!(error = %e, "failed to record sync change");
|
||||
}
|
||||
|
||||
// Record audit
|
||||
pinakes_core::audit::record_action(
|
||||
|
|
@ -1139,7 +1149,9 @@ pub async fn permanent_delete_media(
|
|||
changed_by_device: None,
|
||||
timestamp: chrono::Utc::now(),
|
||||
};
|
||||
let _ = state.storage.record_sync_change(&change).await;
|
||||
if let Err(e) = state.storage.record_sync_change(&change).await {
|
||||
tracing::warn!(error = %e, "failed to record sync change");
|
||||
}
|
||||
|
||||
// Clean up thumbnail
|
||||
if let Some(ref thumb_path) = item.thumbnail_path
|
||||
|
|
|
|||
|
|
@ -171,8 +171,10 @@ pub async fn create_share(
|
|||
created_at: Utc::now(),
|
||||
};
|
||||
|
||||
// Ignore notification errors
|
||||
let _ = state.storage.create_share_notification(¬ification).await;
|
||||
if let Err(e) = state.storage.create_share_notification(¬ification).await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to send share notification");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Json(created.into()))
|
||||
|
|
@ -188,7 +190,7 @@ pub async fn list_outgoing(
|
|||
let user_id = resolve_user_id(&state.storage, &username).await?;
|
||||
let pagination = Pagination {
|
||||
offset: params.offset.unwrap_or(0),
|
||||
limit: params.limit.unwrap_or(50),
|
||||
limit: params.limit.unwrap_or(50).min(1000),
|
||||
sort: params.sort,
|
||||
};
|
||||
|
||||
|
|
@ -211,7 +213,7 @@ pub async fn list_incoming(
|
|||
let user_id = resolve_user_id(&state.storage, &username).await?;
|
||||
let pagination = Pagination {
|
||||
offset: params.offset.unwrap_or(0),
|
||||
limit: params.limit.unwrap_or(50),
|
||||
limit: params.limit.unwrap_or(50).min(1000),
|
||||
sort: params.sort,
|
||||
};
|
||||
|
||||
|
|
@ -316,7 +318,10 @@ pub async fn update_share(
|
|||
is_read: false,
|
||||
created_at: Utc::now(),
|
||||
};
|
||||
let _ = state.storage.create_share_notification(¬ification).await;
|
||||
if let Err(e) = state.storage.create_share_notification(¬ification).await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to send share update notification");
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Json(updated.into()))
|
||||
|
|
@ -351,7 +356,10 @@ pub async fn delete_share(
|
|||
is_read: false,
|
||||
created_at: Utc::now(),
|
||||
};
|
||||
let _ = state.storage.create_share_notification(¬ification).await;
|
||||
if let Err(e) = state.storage.create_share_notification(¬ification).await
|
||||
{
|
||||
tracing::warn!(error = %e, "failed to send share revocation notification");
|
||||
}
|
||||
}
|
||||
|
||||
state.storage.delete_share(ShareId(id)).await.map_err(|e| {
|
||||
|
|
@ -442,7 +450,9 @@ pub async fn access_shared(
|
|||
details: None,
|
||||
timestamp: Utc::now(),
|
||||
};
|
||||
let _ = state.storage.record_share_activity(&activity).await;
|
||||
if let Err(e) = state.storage.record_share_activity(&activity).await {
|
||||
tracing::warn!(error = %e, "failed to record share activity");
|
||||
}
|
||||
|
||||
return Err(ApiError::unauthorized("Invalid password"));
|
||||
}
|
||||
|
|
@ -511,7 +521,7 @@ pub async fn get_activity(
|
|||
|
||||
let pagination = Pagination {
|
||||
offset: params.offset.unwrap_or(0),
|
||||
limit: params.limit.unwrap_or(50),
|
||||
limit: params.limit.unwrap_or(50).min(1000),
|
||||
sort: params.sort,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -266,7 +266,7 @@ pub async fn get_changes(
|
|||
drop(config);
|
||||
|
||||
let cursor = params.cursor.unwrap_or(0);
|
||||
let limit = params.limit.unwrap_or(DEFAULT_CHANGES_LIMIT);
|
||||
let limit = params.limit.unwrap_or(DEFAULT_CHANGES_LIMIT).min(1000);
|
||||
|
||||
let changes = state
|
||||
.storage
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue