KamoCRM

Do not bill an org twice for a version that owns no bytes

Fixkamo-shared-library
Shipped
22 ஆகஸ்ட், 2026 அன்று 6:40 AM UTC
Author
Kamo
Commit
8a7b7fd

The org storage total is SUM(fileSize) over Img rows, and a derived version points at its original's ImgDat while copying its fileSize — so every modified version would have added its original's size to the bill a second time. Since merely opening a document to edit it derives one, that would eventually have doubled most of the total. A version now counts only once a save has given it an ImgDat of its own, at which point the bytes are real. The LEFT JOIN is load-bearing: navigating i.originalImg.dat in the WHERE clause is an implicit INNER join in HQL and would silently drop every row whose originalImg is null — every original, i.e. nearly the whole total. The failure mode is a storage figure that collapses to almost nothing with no error anywhere, so the query shape is pinned by tests.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing