From 8aede4e0820019e52352f0bc3f8bd6bb60e14e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois-Xavier=20Talbot?= <108630700+fetchfern@users.noreply.github.com> Date: Mon, 1 Sep 2025 15:59:09 +0100 Subject: [PATCH] Revert decimal rounding order, fix profile settings (#4314) * Revert rounding post subtraction in GET balance * Switch to panic = "unwind" in release mode * Use profile 'release-labrinth' * Fix target path --- Cargo.toml | 5 +++++ apps/labrinth/Dockerfile | 4 ++-- apps/labrinth/src/routes/v3/payouts.rs | 4 +++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8bdf0437b..07485bb3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -231,5 +231,10 @@ lto = true # Enables link to optimizations panic = "abort" # Strip expensive panic clean-up logic codegen-units = 1 # Compile crates one after another so the compiler can optimize better +# Specific profile for labrinth production builds +[profile.release-labrinth] +inherits = "release" +panic = "unwind" # Don't exit the whole app on panic in production + [profile.dev.package.sqlx-macros] opt-level = 3 diff --git a/apps/labrinth/Dockerfile b/apps/labrinth/Dockerfile index 5351c5088..3df71b8c7 100644 --- a/apps/labrinth/Dockerfile +++ b/apps/labrinth/Dockerfile @@ -8,13 +8,13 @@ ARG GIT_HASH RUN --mount=type=cache,target=/usr/src/labrinth/target \ --mount=type=cache,target=/usr/local/cargo/git/db \ --mount=type=cache,target=/usr/local/cargo/registry \ - SQLX_OFFLINE=true cargo build --release --package labrinth + SQLX_OFFLINE=true cargo build --profile release-labrinth --package labrinth FROM build AS artifacts RUN --mount=type=cache,target=/usr/src/labrinth/target \ mkdir /labrinth \ - && cp /usr/src/labrinth/target/release/labrinth /labrinth/labrinth \ + && cp /usr/src/labrinth/target/release-labrinth/labrinth /labrinth/labrinth \ && cp -r /usr/src/labrinth/apps/labrinth/migrations /labrinth \ && cp -r /usr/src/labrinth/apps/labrinth/assets /labrinth diff --git a/apps/labrinth/src/routes/v3/payouts.rs b/apps/labrinth/src/routes/v3/payouts.rs index 1e9a5b453..7535fcd12 100644 --- a/apps/labrinth/src/routes/v3/payouts.rs +++ b/apps/labrinth/src/routes/v3/payouts.rs @@ -1028,7 +1028,9 @@ async fn get_user_balance( }); Ok(UserBalance { - available: (available - withdrawn - fees).round_dp(16), + available: available.round_dp(16) + - withdrawn.round_dp(16) + - fees.round_dp(16), withdrawn_lifetime: withdrawn.round_dp(16), withdrawn_ytd: withdrawn_this_year.round_dp(16), pending,