Mercurial > prosody-modules
diff mod_http_upload/mod_http_upload.lua @ 2800:8d9aed6d1f87
mod_http_upload: Only try to create a randomly named directory once.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 17 Oct 2017 22:39:37 +0200 |
parents | e1edf643fbb1 |
children | faec53f4b31e |
line wrap: on
line diff
--- a/mod_http_upload/mod_http_upload.lua Sun Oct 15 11:10:37 2017 +0200 +++ b/mod_http_upload/mod_http_upload.lua Tue Oct 17 22:39:37 2017 +0200 @@ -135,10 +135,13 @@ return nil, st.error_reply(stanza, "wait", "resource-constraint", "Quota reached"); end - local random_dir; - repeat random_dir = uuid(); - until lfs.mkdir(join_path(storage_path, random_dir)) - or not lfs.attributes(join_path(storage_path, random_dir, filename)) + local random_dir = uuid(); + local created, err = lfs.mkdir(join_path(storage_path, random_dir)); + + if not created then + module:log("error", "Could not create directory for slot: %s", err); + return nil, st.error_reply(stanza, "wait", "internal-server-failure"); + end local ok = datamanager.list_append(username, host, module.name, { filename = filename, dir = random_dir, size = filesize, time = os.time() });