Comparison

plugins/mod_http_file_share.lua @ 11493:77f2d45799ed

mod_http_file_share: Fix reporting of missing files This just gave an unhelpful 500 error. It would be nice to have some wrapper code that could untangle the embedded filename in the io libs errors.
author Kim Alvefur <zash@zash.se>
date Sun, 28 Mar 2021 13:51:06 +0200
parent 11491:c3fb802f9e45
child 11495:6d3f84148729
comparison
equal deleted inserted replaced
11492:6da8d9cb355d 11493:77f2d45799ed
337 local last_modified = os.date('!%a, %d %b %Y %H:%M:%S GMT', filetime); 337 local last_modified = os.date('!%a, %d %b %Y %H:%M:%S GMT', filetime);
338 if request.headers.if_modified_since == last_modified then 338 if request.headers.if_modified_since == last_modified then
339 return 304; 339 return 304;
340 end 340 end
341 local filename = get_filename(slot_id); 341 local filename = get_filename(slot_id);
342 local handle, ferr = errors.coerce(io.open(filename)); 342 local handle, ferr = io.open(filename);
343 if not handle then 343 if not handle then
344 return ferr or 410; 344 module:log("error", "Could not open file: %s", filename, ferr);
345 -- This can be because the upload slot wasn't used, or the file disappeared
346 -- somehow, or permission issues.
347 return 410;
345 end 348 end
346 349
347 if not filetype then 350 if not filetype then
348 filetype = "application/octet-stream"; 351 filetype = "application/octet-stream";
349 end 352 end