mod_http_file_share: Retrieve stored total in async-friendly way
authorKim Alvefur <zash@zash.se>
Sat, 14 Oct 2023 22:43:39 +0200
changeset 13270 9c62ffbdf2ae
parent 13269 6ac5ad578565
child 13272 081f8f9b3b81
mod_http_file_share: Retrieve stored total in async-friendly way Does this run in a thread?
plugins/mod_http_file_share.lua
--- a/plugins/mod_http_file_share.lua	Sat Oct 14 22:32:33 2023 +0200
+++ b/plugins/mod_http_file_share.lua	Sat Oct 14 22:43:39 2023 +0200
@@ -79,12 +79,12 @@
 local measure_quota_cache_size = module:measure("quota_cache", "amount");
 local measure_total_storage_usage = module:measure("total_storage", "amount", { unit = "bytes" });
 
-do
+module:once(function ()
 	local total, err = persist_stats:get(nil, "total");
 	if not err then
 		total_storage_usage = tonumber(total) or 0;
 	end
-end
+end)
 
 module:hook_global("stats-update", function ()
 	measure_upload_cache_size(upload_cache:count());