Comparison

plugins/mod_http_file_share.lua @ 11375:6b687210975b

mod_http_file_share: Prevent attempt to upload again after completion
author Kim Alvefur <zash@zash.se>
date Sat, 13 Feb 2021 14:14:12 +0100
parent 11374:5b8aec0609f0
child 11394:420787340339
comparison
equal deleted inserted replaced
11374:5b8aec0609f0 11375:6b687210975b
222 -- so we also check the final file size on completion. 222 -- so we also check the final file size on completion.
223 end 223 end
224 224
225 local filename = get_filename(upload_info.slot, true); 225 local filename = get_filename(upload_info.slot, true);
226 226
227 do
228 -- check if upload has been completed already
229 -- we want to allow retry of a failed upload attempt, but not after it's been completed
230 local f = io.open(filename, "r");
231 if f then
232 f:close();
233 return 409;
234 end
235 end
227 236
228 if not request.body_sink then 237 if not request.body_sink then
229 module:log("debug", "Preparing to receive upload into %q, expecting %s", filename, B(upload_info.filesize)); 238 module:log("debug", "Preparing to receive upload into %q, expecting %s", filename, B(upload_info.filesize));
230 local fh, err = errors.coerce(io.open(filename.."~", "w")); 239 local fh, err = errors.coerce(io.open(filename.."~", "w"));
231 if not fh then 240 if not fh then