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:
raf 2026-03-07 16:55:43 +03:00
commit f049dd100a
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
3 changed files with 37 additions and 15 deletions

View file

@ -862,7 +862,9 @@ pub async fn rename_media(
changed_by_device: None, changed_by_device: None,
timestamp: chrono::Utc::now(), 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 // Record audit
pinakes_core::audit::record_action( pinakes_core::audit::record_action(
@ -902,7 +904,9 @@ pub async fn move_media_endpoint(
changed_by_device: None, changed_by_device: None,
timestamp: chrono::Utc::now(), 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 // Record audit
pinakes_core::audit::record_action( pinakes_core::audit::record_action(
@ -958,7 +962,9 @@ pub async fn batch_move_media(
changed_by_device: None, changed_by_device: None,
timestamp: chrono::Utc::now(), 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, changed_by_device: None,
timestamp: chrono::Utc::now(), 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 // Record audit
pinakes_core::audit::record_action( pinakes_core::audit::record_action(
@ -1040,7 +1048,9 @@ pub async fn restore_media(
changed_by_device: None, changed_by_device: None,
timestamp: chrono::Utc::now(), 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 // Record audit
pinakes_core::audit::record_action( pinakes_core::audit::record_action(
@ -1139,7 +1149,9 @@ pub async fn permanent_delete_media(
changed_by_device: None, changed_by_device: None,
timestamp: chrono::Utc::now(), 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 // Clean up thumbnail
if let Some(ref thumb_path) = item.thumbnail_path if let Some(ref thumb_path) = item.thumbnail_path

View file

@ -171,8 +171,10 @@ pub async fn create_share(
created_at: Utc::now(), created_at: Utc::now(),
}; };
// Ignore notification errors if let Err(e) = state.storage.create_share_notification(&notification).await
let _ = state.storage.create_share_notification(&notification).await; {
tracing::warn!(error = %e, "failed to send share notification");
}
} }
Ok(Json(created.into())) Ok(Json(created.into()))
@ -188,7 +190,7 @@ pub async fn list_outgoing(
let user_id = resolve_user_id(&state.storage, &username).await?; let user_id = resolve_user_id(&state.storage, &username).await?;
let pagination = Pagination { let pagination = Pagination {
offset: params.offset.unwrap_or(0), offset: params.offset.unwrap_or(0),
limit: params.limit.unwrap_or(50), limit: params.limit.unwrap_or(50).min(1000),
sort: params.sort, sort: params.sort,
}; };
@ -211,7 +213,7 @@ pub async fn list_incoming(
let user_id = resolve_user_id(&state.storage, &username).await?; let user_id = resolve_user_id(&state.storage, &username).await?;
let pagination = Pagination { let pagination = Pagination {
offset: params.offset.unwrap_or(0), offset: params.offset.unwrap_or(0),
limit: params.limit.unwrap_or(50), limit: params.limit.unwrap_or(50).min(1000),
sort: params.sort, sort: params.sort,
}; };
@ -316,7 +318,10 @@ pub async fn update_share(
is_read: false, is_read: false,
created_at: Utc::now(), created_at: Utc::now(),
}; };
let _ = state.storage.create_share_notification(&notification).await; if let Err(e) = state.storage.create_share_notification(&notification).await
{
tracing::warn!(error = %e, "failed to send share update notification");
}
} }
Ok(Json(updated.into())) Ok(Json(updated.into()))
@ -351,7 +356,10 @@ pub async fn delete_share(
is_read: false, is_read: false,
created_at: Utc::now(), created_at: Utc::now(),
}; };
let _ = state.storage.create_share_notification(&notification).await; if let Err(e) = state.storage.create_share_notification(&notification).await
{
tracing::warn!(error = %e, "failed to send share revocation notification");
}
} }
state.storage.delete_share(ShareId(id)).await.map_err(|e| { state.storage.delete_share(ShareId(id)).await.map_err(|e| {
@ -442,7 +450,9 @@ pub async fn access_shared(
details: None, details: None,
timestamp: Utc::now(), 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")); return Err(ApiError::unauthorized("Invalid password"));
} }
@ -511,7 +521,7 @@ pub async fn get_activity(
let pagination = Pagination { let pagination = Pagination {
offset: params.offset.unwrap_or(0), offset: params.offset.unwrap_or(0),
limit: params.limit.unwrap_or(50), limit: params.limit.unwrap_or(50).min(1000),
sort: params.sort, sort: params.sort,
}; };

View file

@ -266,7 +266,7 @@ pub async fn get_changes(
drop(config); drop(config);
let cursor = params.cursor.unwrap_or(0); 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 let changes = state
.storage .storage