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

Fixkamo-shared-library
Shipped
August 22, 2026 at 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?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing