fix: only add delta bytes when changing app data value

This commit is contained in:
trisua 2025-07-20 03:33:03 -04:00
parent 270d7550d6
commit d58e47cbbe
2 changed files with 9 additions and 2 deletions

View file

@ -160,7 +160,14 @@ pub async fn update_value_request(
}
// ...
if let Err(e) = data.add_app_data_used(app.id, req.value.len() as i32).await {
// we only need to add the delta size (the next size - the old size)
if let Err(e) = data
.add_app_data_used(
app.id,
(req.value.len() as i32) - (app_data.value.len() as i32),
)
.await
{
return Json(e.into());
}

View file

@ -5,7 +5,7 @@ use crate::{auto_method, DataManager};
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
pub const FREE_DATA_LIMIT: usize = 512_000;
pub const PASS_DATA_LIMIT: usize = 5_242_880;
pub const PASS_DATA_LIMIT: usize = 26_214_400;
impl DataManager {
/// Get a [`AppData`] from an SQL row.