Changeset

2688:ef80c9d0ebff

mod_http_upload: Remove unused upload slots
author Kim Alvefur <zash@zash.se>
date Sat, 15 Apr 2017 15:51:29 +0200
parents 2687:5f0b755b42a3
children 2689:0fc706855af9
files mod_http_upload/mod_http_upload.lua
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_upload/mod_http_upload.lua	Sat Apr 15 15:35:55 2017 +0200
+++ b/mod_http_upload/mod_http_upload.lua	Sat Apr 15 15:51:29 2017 +0200
@@ -79,6 +79,7 @@
 	if not uploads then return true; end
 	uploads = array(uploads);
 	local expiry = os.time() - max_age;
+	local upload_window = os.time() - 900;
 	uploads:filter(function (item)
 		if item.time < expiry then
 			local deleted, whynot = os.remove(item.filename);
@@ -86,6 +87,8 @@
 				module:log("warn", "Could not delete expired upload %s: %s", item.filename, whynot or "delete failed");
 			end
 			return false;
+		elseif item.time < upload_window and not lfs.attributes(item.filename) then
+			return false; -- File was not uploaded or has been deleted since
 		end
 		return true;
 	end);