Changeset

11375:6b687210975b

mod_http_file_share: Prevent attempt to upload again after completion
author Kim Alvefur <zash@zash.se>
date Sat, 13 Feb 2021 14:14:12 +0100
parents 11374:5b8aec0609f0
children 11378:b790df8f9448
files plugins/mod_http_file_share.lua
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_http_file_share.lua	Sat Feb 13 14:06:46 2021 +0100
+++ b/plugins/mod_http_file_share.lua	Sat Feb 13 14:14:12 2021 +0100
@@ -224,6 +224,15 @@
 
 	local filename = get_filename(upload_info.slot, true);
 
+	do
+		-- check if upload has been completed already
+		-- we want to allow retry of a failed upload attempt, but not after it's been completed
+		local f = io.open(filename, "r");
+		if f then
+			f:close();
+			return 409;
+		end
+	end
 
 	if not request.body_sink then
 		module:log("debug", "Preparing to receive upload into %q, expecting %s", filename, B(upload_info.filesize));