fix: only add delta bytes when changing app data value
This commit is contained in:
parent
270d7550d6
commit
d58e47cbbe
2 changed files with 9 additions and 2 deletions
|
@ -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());
|
return Json(e.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::{auto_method, DataManager};
|
||||||
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
use oiseau::{PostgresRow, execute, get, query_row, query_rows, params};
|
||||||
|
|
||||||
pub const FREE_DATA_LIMIT: usize = 512_000;
|
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 {
|
impl DataManager {
|
||||||
/// Get a [`AppData`] from an SQL row.
|
/// Get a [`AppData`] from an SQL row.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue