Mercurial > prosody-hg
comparison plugins/mod_http_file_share.lua @ 11594:19aac4247b03
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}
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 08 Jun 2021 13:33:40 +0200 |
| parents | d5360307a99d |
| children | a6d1131ac833 |
comparison
equal
deleted
inserted
replaced
| 11593:0db763f3f3be | 11594:19aac4247b03 |
|---|---|
| 69 module:hook_global("stats-update", function () | 69 module:hook_global("stats-update", function () |
| 70 measure_upload_cache_size(upload_cache:count()); | 70 measure_upload_cache_size(upload_cache:count()); |
| 71 measure_quota_cache_size(quota_cache:count()); | 71 measure_quota_cache_size(quota_cache:count()); |
| 72 end); | 72 end); |
| 73 | 73 |
| 74 local measure_uploads = module:measure("upload", "sizes"); | 74 local buckets = {}; |
| 75 for n = 10, 40, 2 do | |
| 76 local exp = math.floor(2 ^ n); | |
| 77 table.insert(buckets, exp); | |
| 78 if exp >= file_size_limit then break end | |
| 79 end | |
| 80 local measure_uploads = module:measure("upload", "sizes", {buckets = buckets}); | |
| 75 | 81 |
| 76 -- Convenience wrapper for logging file sizes | 82 -- Convenience wrapper for logging file sizes |
| 77 local function B(bytes) return hi.format(bytes, "B", "b"); end | 83 local function B(bytes) return hi.format(bytes, "B", "b"); end |
| 78 | 84 |
| 79 local function get_filename(slot, create) | 85 local function get_filename(slot, create) |
