Software /
code /
prosody
Comparison
plugins/mod_http_file_share.lua @ 13266:9c62ffbdf2ae
mod_http_file_share: Retrieve stored total in async-friendly way
Does this run in a thread?
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 14 Oct 2023 22:43:39 +0200 |
parent | 13259:9097149923ae |
child | 13362:11e66ad894f0 |
comparison
equal
deleted
inserted
replaced
13265:6ac5ad578565 | 13266:9c62ffbdf2ae |
---|---|
77 | 77 |
78 local measure_upload_cache_size = module:measure("upload_cache", "amount"); | 78 local measure_upload_cache_size = module:measure("upload_cache", "amount"); |
79 local measure_quota_cache_size = module:measure("quota_cache", "amount"); | 79 local measure_quota_cache_size = module:measure("quota_cache", "amount"); |
80 local measure_total_storage_usage = module:measure("total_storage", "amount", { unit = "bytes" }); | 80 local measure_total_storage_usage = module:measure("total_storage", "amount", { unit = "bytes" }); |
81 | 81 |
82 do | 82 module:once(function () |
83 local total, err = persist_stats:get(nil, "total"); | 83 local total, err = persist_stats:get(nil, "total"); |
84 if not err then | 84 if not err then |
85 total_storage_usage = tonumber(total) or 0; | 85 total_storage_usage = tonumber(total) or 0; |
86 end | 86 end |
87 end | 87 end) |
88 | 88 |
89 module:hook_global("stats-update", function () | 89 module:hook_global("stats-update", function () |
90 measure_upload_cache_size(upload_cache:count()); | 90 measure_upload_cache_size(upload_cache:count()); |
91 measure_quota_cache_size(quota_cache:count()); | 91 measure_quota_cache_size(quota_cache:count()); |
92 measure_total_storage_usage(total_storage_usage); | 92 measure_total_storage_usage(total_storage_usage); |