Software / code / prosody
Comparison
plugins/mod_http_file_share.lua @ 11994:f9b2325f6b50
mod_http_file_share: Keep global storage use accurate longer.
Merging those loops removes the miscounting that would occur in case a
file could not be deleted, so no need to limit it to that case.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 30 Nov 2021 00:55:54 +0100 |
| parent | 11993:aa60f4353001 |
| child | 11998:99be6874340b |
comparison
equal
deleted
inserted
replaced
| 11993:aa60f4353001 | 11994:f9b2325f6b50 |
|---|---|
| 498 -- deleted and that needs to be cleared from the database | 498 -- deleted and that needs to be cleared from the database |
| 499 | 499 |
| 500 local deletion_query = {["end"] = boundary_time}; | 500 local deletion_query = {["end"] = boundary_time}; |
| 501 if not problem_deleting then | 501 if not problem_deleting then |
| 502 module:log("info", "All (%d, %s) expired files successfully deleted", n, B(size_sum)); | 502 module:log("info", "All (%d, %s) expired files successfully deleted", n, B(size_sum)); |
| 503 if total_storage_usage then | |
| 504 total_storage_usage = total_storage_usage - size_sum; | |
| 505 module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit)); | |
| 506 end | |
| 507 -- we can delete based on time | 503 -- we can delete based on time |
| 508 else | 504 else |
| 509 module:log("warn", "%d out of %d expired files could not be deleted", n-#obsolete_uploads, n); | 505 module:log("warn", "%d out of %d expired files could not be deleted", n-#obsolete_uploads, n); |
| 510 -- we'll need to delete only those entries where the files were | 506 -- we'll need to delete only those entries where the files were |
| 511 -- successfully deleted, and then try again with the failed ones. | 507 -- successfully deleted, and then try again with the failed ones. |
| 512 -- eventually the admin ought to notice and fix the permissions or | 508 -- eventually the admin ought to notice and fix the permissions or |
| 513 -- whatever the problem is. | 509 -- whatever the problem is. |
| 514 -- total_storage_limit will be inaccurate until this has been resolved | |
| 515 deletion_query = {ids = obsolete_uploads}; | 510 deletion_query = {ids = obsolete_uploads}; |
| 511 end | |
| 512 | |
| 513 if total_storage_usage then | |
| 514 total_storage_usage = total_storage_usage - size_sum; | |
| 515 module:log("debug", "Global quota %s / %s", B(total_storage_usage), B(total_storage_limit)); | |
| 516 end | 516 end |
| 517 | 517 |
| 518 if #obsolete_uploads == 0 then | 518 if #obsolete_uploads == 0 then |
| 519 module:log("debug", "No metadata to remove"); | 519 module:log("debug", "No metadata to remove"); |
| 520 else | 520 else |