mod_http_upload/mod_http_upload.lua
changeset 2473 43f7637f0143
parent 2472 3bff2848af12
child 2474 9ff809591fbc
--- a/mod_http_upload/mod_http_upload.lua	Sun Jan 29 17:30:25 2017 +0100
+++ b/mod_http_upload/mod_http_upload.lua	Sun Jan 29 17:31:28 2017 +0100
@@ -123,6 +123,10 @@
 	end
 	pending_slots[path] = nil;
 	local full_filename = join_path(dirname, filename);
+	if lfs.attributes(full_filename) then
+		module:log("warn", "File %s exists already, not replacing it", full_filename);
+		return 409;
+	end
 	local fh, ferr = io.open(full_filename, "w");
 	if not fh then
 		module:log("error", "Could not open file %s for upload: %s", full_filename, ferr);