Diff

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
line wrap: on
line diff
--- 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());