Mercurial > prosody-modules
diff mod_http_upload/mod_http_upload.lua @ 2469:43f7637f0143
mod_http_upload: Make sure that target file does not exist prior to upload
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 29 Jan 2017 17:31:28 +0100 |
parents | 3bff2848af12 |
children | 9ff809591fbc |
line wrap: on
line diff
--- 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);