Comparison

plugins/mod_http_file_share.lua @ 11316:ae0461b37fbe

mod_http_file_share: Verify final file size on completion of upload
author Kim Alvefur <zash@zash.se>
date Wed, 27 Jan 2021 00:09:49 +0100
parent 11315:c52fcea39c8e
child 11317:79e1f407b6f5
comparison
equal deleted inserted replaced
11315:c52fcea39c8e 11316:ae0461b37fbe
171 end 171 end
172 request.body = nil; 172 request.body = nil;
173 end 173 end
174 174
175 if request.body_sink then 175 if request.body_sink then
176 local final_size = request.body_sink:seek();
176 local uploaded, err = errors.coerce(request.body_sink:close()); 177 local uploaded, err = errors.coerce(request.body_sink:close());
178 if final_size ~= upload_info.filesize then
179 -- Could be too short as well, but we say the same thing
180 uploaded, err = false, 413;
181 end
177 if uploaded then 182 if uploaded then
178 assert(os.rename(filename.."~", filename)); 183 assert(os.rename(filename.."~", filename));
179 return 201; 184 return 201;
180 else 185 else
181 assert(os.remove(filename.."~")); 186 assert(os.remove(filename.."~"));