diff mod_http_upload/mod_http_upload.lua @ 3659:bb8a6df5ecba

mod_http_upload: Skip write if nothing expired when checking Reducing unnecessary IO is good.
author Kim Alvefur <zash@zash.se>
date Thu, 29 Aug 2019 23:35:42 +0200
parents 02a1615d0392
children 88d414c916ee
line wrap: on
line diff
--- 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