mod_http_upload: Skip write if nothing expired when checking
Reducing unnecessary IO is good.
--- a/mod_http_upload/mod_http_upload.lua Thu Aug 29 23:30:55 2019 +0200
+++ b/mod_http_upload/mod_http_upload.lua Thu Aug 29 23:35:42 2019 +0200
@@ -119,6 +119,7 @@
uploads = array(uploads);
local expiry = os.time() - max_age;
local upload_window = os.time() - 900;
+ local before = #uploads;
uploads:filter(function (item)
local filename = item.filename;
if item.dir then
@@ -136,6 +137,8 @@
end
return true;
end);
+ local after = #uploads;
+ if before == after then return true end -- nothing changed, skip write
return datamanager.list_store(username, host, module.name, uploads);
end