CommunityServer icon indicating copy to clipboard operation
CommunityServer copied to clipboard

Where are these negative space usage numbers from?

Open NangeGao opened this issue 1 year ago • 1 comments

I want to query the space usage of all users in the database, but why are there negative numbers?

SQL:

SELECT core_user.username, tenants_quotarow.path, tenants_quotarow.counter / (1024 * 1024 * 1024) AS counter_in_gb
FROM core_user
JOIN tenants_quotarow ON core_user.id = tenants_quotarow.user_id
ORDER BY tenants_quotarow.counter DESC;

Results:

+-------------------+----------------------+---------------+
| username          | path                 | counter_in_gb |
+-------------------+----------------------+---------------+
| user1              | /files/files_temp   |      392.4970 |
| user2              | /files/             |      347.2974 |
| user3              | /files/             |      320.8614 |
...
...
...
| user1001          | /files/files_temp    |        0.0000 |
| user1002          | /files/files_temp    |        0.0000 |
| user1003          | /files/files_temp    |        0.0000 |
| user1004          | /files/files_temp    |       -0.0001 |
| user1005          | /files/files_temp    |       -0.0001 |
| user1006          | /files/              |       -0.0002 |
| user1007          | /files/              |       -1.8555 |
| user1008          | /files/              |       -3.7923 |
| user1009          | /files/              |      -10.6667 |
| user1010          | /files/              |      -24.0484 |
| user1011          | /files/              |     -381.7321 |
+-------------------+----------------------+---------------+

NangeGao avatar Mar 21 '25 02:03 NangeGao

https://github.com/ONLYOFFICE/CommunityServer/blob/7c503dfb5e9fe1a0b520d7d2a47ef857b37771b5/common/ASC.Data.Storage/TenantQuotaController.cs#L135

The code snippet calculates the total disk space used by a specific user and ensures that it is non-negative.

NangeGao avatar Mar 21 '25 07:03 NangeGao