# HG changeset patch # User Kim Alvefur # Date 1492264539 -7200 # Node ID 92ddfc548ce8131e77d634e8c1d3690841aedbe0 # Parent 43ad92c5b91a0791de7ca731ce4d0d711a7071db mod_http_upload: Store filename and directory separately diff -r 43ad92c5b91a -r 92ddfc548ce8 mod_http_upload/mod_http_upload.lua --- a/mod_http_upload/mod_http_upload.lua Sat Apr 15 15:53:46 2017 +0200 +++ b/mod_http_upload/mod_http_upload.lua Sat Apr 15 15:55:39 2017 +0200 @@ -81,13 +81,17 @@ local expiry = os.time() - max_age; local upload_window = os.time() - 900; uploads:filter(function (item) + local filename = item.filename; + if item.dir then + filename = join_path(storage_path, item.dir, item.filename); + end if item.time < expiry then - local deleted, whynot = os.remove(item.filename); + local deleted, whynot = os.remove(filename); if not deleted then - module:log("warn", "Could not delete expired upload %s: %s", item.filename, whynot or "delete failed"); + module:log("warn", "Could not delete expired upload %s: %s", filename, whynot or "delete failed"); end return false; - elseif item.time < upload_window and not lfs.attributes(item.filename) then + elseif item.time < upload_window and not lfs.attributes(filename) then return false; -- File was not uploaded or has been deleted since end return true; @@ -161,7 +165,8 @@ or not lfs.attributes(join_path(storage_path, random_dir, filename)) local ok = datamanager.list_append(username, host, module.name, { - filename = join_path(storage_path, random_dir, filename), size = filesize, time = os.time() }); + filename = filename, dir = random_dir, size = filesize, time = os.time() }); + if not ok then origin.send(st.error_reply(stanza, "wait", "internal-server-failure")); return true;