# HG changeset patch # User Kim Alvefur # Date 1540772489 -3600 # Node ID 6d1c5ecf72c1a148afc9dab41904da64b105e9ca # Parent a5a5f85d7ca1edd88b613bc28ce5d370ece36c7f mod_http_upload: Report statistics on upload sizes (0.10+) diff -r a5a5f85d7ca1 -r 6d1c5ecf72c1 mod_http_upload/mod_http_upload.lua --- a/mod_http_upload/mod_http_upload.lua Mon Oct 29 01:10:10 2018 +0100 +++ b/mod_http_upload/mod_http_upload.lua Mon Oct 29 01:21:29 2018 +0100 @@ -109,6 +109,13 @@ return sum < quota; end +local measure_slot = function () end +if module.measure then + -- COMPAT 0.9 + -- module:measure was added in 0.10 + measure_slot = module:measure("sizes", "slot"); +end + local function handle_request(origin, stanza, xmlns, filename, filesize) local username, host = origin.username, origin.host; -- local clients only @@ -157,6 +164,8 @@ pending_slots[slot] = nil; end); + measure_slot(filesize); + origin.log("debug", "Given upload slot %q", slot); local base_url = module:http_url(); @@ -213,6 +222,13 @@ return true; end); +local measure_upload = function () end +if module.measure then + -- COMPAT 0.9 + -- module:measure was added in 0.10 + measure_upload = module:measure("sizes", "upload"); +end + -- http service local function upload_data(event, path) local uploader = pending_slots[path]; @@ -252,6 +268,7 @@ os.remove(full_filename); return 500; end + measure_upload(#event.request.body); module:log("info", "File uploaded by %s to slot %s", uploader, random_dir); return 201; end