comparison mod_http_upload/mod_http_upload.lua @ 2479:a440f0514c2a

Backed out changeset f48e9e25aec4, util.uuid.get_nibbles is unavailable in 0.9
author Kim Alvefur <zash@zash.se>
date Tue, 31 Jan 2017 14:05:53 +0100
parents 1fae2a0a4092
children 9d154c929319
comparison
equal deleted inserted replaced
2478:1fae2a0a4092 2479:a440f0514c2a
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 random_hex = require"util.uuid".get_nibbles; 13 local uuid = require"util.uuid".generate;
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 datamanager = require "util.datamanager"; 16 local datamanager = require "util.datamanager";
17 local t_concat = table.concat; 17 local t_concat = table.concat;
18 local t_insert = table.insert; 18 local t_insert = table.insert;
85 end 85 end
86 local reply = st.reply(stanza); 86 local reply = st.reply(stanza);
87 reply:tag("slot", { xmlns = xmlns_http_upload }); 87 reply:tag("slot", { xmlns = xmlns_http_upload });
88 88
89 local random; 89 local random;
90 repeat random = random_hex(12); 90 repeat random = uuid();
91 until lfs.mkdir(join_path(storage_path, random)) or not lfs.attributes(join_path(storage_path, random, filename)) 91 until lfs.mkdir(join_path(storage_path, random)) or not lfs.attributes(join_path(storage_path, random, filename))
92 92
93 datamanager.list_append(origin.username, origin.host, module.name, { filename = join_path(storage_path, random, filename), size = filesize, time = os.time() }); 93 datamanager.list_append(origin.username, origin.host, module.name, { filename = join_path(storage_path, random, filename), size = filesize, time = os.time() });
94 pending_slots[random.."/"..filename] = origin.full_jid; 94 pending_slots[random.."/"..filename] = origin.full_jid;
95 local base_url = module:http_url(); 95 local base_url = module:http_url();