plugins/mod_http_file_share.lua
changeset 11868 fceebfb28d86
parent 11861 e080d6aa0b3b
child 11869 77bbbd4263d7
--- a/plugins/mod_http_file_share.lua	Thu Oct 21 21:02:14 2021 +0200
+++ b/plugins/mod_http_file_share.lua	Sat Oct 23 01:53:07 2021 +0200
@@ -289,6 +289,13 @@
 			module:log("error", "Could not open file for writing: %s", err);
 			return 500;
 		end
+		function event.response:on_destroy()
+			-- Clean up incomplete upload
+			if io.type(fh) == "file" then -- still open
+				fh:close();
+				os.remove(filename.."~");
+			end
+		end
 		request.body_sink = fh;
 		if request.body == false then
 			if request.headers.expect == "100-continue" then