Mercurial > prosody-hg
comparison plugins/mod_http_file_share.lua @ 11324:494761f5d7da
mod_http_file_share: Use '.bin' file extension
Distinct from '.dat' used by datamanager / internal stortage for Lua
object storage so that they can't easily be loaded by accident that way.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Wed, 27 Jan 2021 17:48:12 +0100 |
| parents | a853a018eede |
| children | 76fc73d39092 |
comparison
equal
deleted
inserted
replaced
| 11323:a853a018eede | 11324:494761f5d7da |
|---|---|
| 169 return 413; | 169 return 413; |
| 170 -- Note: We don't know the size if the upload is streamed in chunked encoding, | 170 -- Note: We don't know the size if the upload is streamed in chunked encoding, |
| 171 -- so we also check the final file size on completion. | 171 -- so we also check the final file size on completion. |
| 172 end | 172 end |
| 173 | 173 |
| 174 local filename = dm.getpath(upload_info.slot, module.host, module.name, nil, true); | 174 local filename = dm.getpath(upload_info.slot, module.host, module.name, "bin", true); |
| 175 | |
| 175 | 176 |
| 176 if not request.body_sink then | 177 if not request.body_sink then |
| 177 module:log("debug", "Preparing to receive upload into %q, expecting %s", filename, B(upload_info.filesize)); | 178 module:log("debug", "Preparing to receive upload into %q, expecting %s", filename, B(upload_info.filesize)); |
| 178 local fh, err = errors.coerce(io.open(filename.."~", "w")); | 179 local fh, err = errors.coerce(io.open(filename.."~", "w")); |
| 179 if not fh then | 180 if not fh then |
| 226 module:log("debug", "uploads:get(%q) --> %s, %d", slot_id, slot, when); | 227 module:log("debug", "uploads:get(%q) --> %s, %d", slot_id, slot, when); |
| 227 local last_modified = os.date('!%a, %d %b %Y %H:%M:%S GMT', when); | 228 local last_modified = os.date('!%a, %d %b %Y %H:%M:%S GMT', when); |
| 228 if request.headers.if_modified_since == last_modified then | 229 if request.headers.if_modified_since == last_modified then |
| 229 return 304; | 230 return 304; |
| 230 end | 231 end |
| 231 local filename = dm.getpath(slot_id, module.host, module.name); | 232 local filename = dm.getpath(slot_id, module.host, module.name, "bin"); |
| 232 local handle, ferr = errors.coerce(io.open(filename)); | 233 local handle, ferr = errors.coerce(io.open(filename)); |
| 233 if not handle then | 234 if not handle then |
| 234 return ferr or 410; | 235 return ferr or 410; |
| 235 end | 236 end |
| 236 response.headers.last_modified = last_modified; | 237 response.headers.last_modified = last_modified; |
