# HG changeset patch # User Kim Alvefur # Date 1485707488 -3600 # Node ID 43f7637f0143507db6e849fb8ba356debcd01c7b # Parent 3bff2848af1202ff5620c82afa0ee6c8e4a7f714 mod_http_upload: Make sure that target file does not exist prior to upload diff -r 3bff2848af12 -r 43f7637f0143 mod_http_upload/mod_http_upload.lua --- 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);