Comparison

mod_http_upload/mod_http_upload.lua @ 2471:f48e9e25aec4

mod_http_upload: Generate shorter random directory names (see #822)
author Kim Alvefur <zash@zash.se>
date Sun, 29 Jan 2017 17:27:24 +0100
parent 2470:9ff809591fbc
child 2472:595d6a25bd7a
comparison
equal deleted inserted replaced
2470:9ff809591fbc 2471:f48e9e25aec4
8 -- 8 --
9 9
10 -- imports 10 -- imports
11 local st = require"util.stanza"; 11 local st = require"util.stanza";
12 local lfs = require"lfs"; 12 local lfs = require"lfs";
13 local uuid = require"util.uuid".generate; 13 local random_hex = require"util.uuid".get_nibbles;
14 local url = require "socket.url"; 14 local url = require "socket.url";
15 local dataform = require "util.dataforms".new; 15 local dataform = require "util.dataforms".new;
16 local t_concat = table.concat; 16 local t_concat = table.concat;
17 local t_insert = table.insert; 17 local t_insert = table.insert;
18 local s_upper = string.upper; 18 local s_upper = string.upper;
84 end 84 end
85 local reply = st.reply(stanza); 85 local reply = st.reply(stanza);
86 reply:tag("slot", { xmlns = xmlns_http_upload }); 86 reply:tag("slot", { xmlns = xmlns_http_upload });
87 87
88 local random; 88 local random;
89 repeat random = uuid(); 89 repeat random = random_hex(12);
90 until lfs.mkdir(join_path(storage_path, random)) or not lfs.attributes(join_path(storage_path, random, filename)) 90 until lfs.mkdir(join_path(storage_path, random)) or not lfs.attributes(join_path(storage_path, random, filename))
91 91
92 pending_slots[random.."/"..filename] = origin.full_jid; 92 pending_slots[random.."/"..filename] = origin.full_jid;
93 local base_url = module:http_url(); 93 local base_url = module:http_url();
94 local slot_url = url.parse(base_url); 94 local slot_url = url.parse(base_url);