mod_http_file_share: Build list of measuring buckets for configured size limit

Creates buckets up to the configured size limit or 1TB, whichever is
smaller, e.g. {1K, 4K, 16K, ... 4M, 16M}
pull/26/head
Kim Alvefur 5 years ago
parent 4abc78fb2f
commit 2f7da2c6ea
  1. 8
      plugins/mod_http_file_share.lua

@ -71,7 +71,13 @@ module:hook_global("stats-update", function ()
measure_quota_cache_size(quota_cache:count());
end);
local measure_uploads = module:measure("upload", "sizes");
local buckets = {};
for n = 10, 40, 2 do
local exp = math.floor(2 ^ n);
table.insert(buckets, exp);
if exp >= file_size_limit then break end
end
local measure_uploads = module:measure("upload", "sizes", {buckets = buckets});
-- Convenience wrapper for logging file sizes
local function B(bytes) return hi.format(bytes, "B", "b"); end

Loading…
Cancel
Save