Comparison

plugins/mod_http_file_share.lua @ 11347:5b3ad3c7fe47

mod_http_file_share: Split out some variables for later reuse
author Kim Alvefur <zash@zash.se>
date Sun, 31 Jan 2021 17:56:35 +0100
parent 11346:315faec1a920
child 11348:f076199b4d38
comparison
equal deleted inserted replaced
11346:315faec1a920 11347:5b3ad3c7fe47
68 return dm.getpath(slot, module.host, module.name, "bin", create) 68 return dm.getpath(slot, module.host, module.name, "bin", create)
69 end 69 end
70 70
71 -- TODO cache 71 -- TODO cache
72 function get_daily_quota(uploader) 72 function get_daily_quota(uploader)
73 local iter, err = uploads:find(nil, {with = uploader; start = os.time() - 86400}); 73 local now = os.time();
74 local max_age = now - 86400;
75 local iter, err = uploads:find(nil, {with = uploader; start = max_age });
74 if not iter then return iter, err; end 76 if not iter then return iter, err; end
75 local total_bytes = 0; 77 local total_bytes = 0;
76 for _, slot in iter do 78 for _, slot in iter do
77 local size = tonumber(slot.attr.size); 79 local size = tonumber(slot.attr.size);
78 if size then total_bytes = total_bytes + size; end 80 if size then total_bytes = total_bytes + size; end