Changeset

2649:abea818eed7b

mod_http_upload: Rename variable to avoid name clash
author Kim Alvefur <zash@zash.se>
date Sun, 26 Mar 2017 23:07:16 +0200 (2017-03-26)
parents 2648:4c92e2e897c8
children 2650:fef067b57305
files mod_http_upload/mod_http_upload.lua
diffstat 1 files changed, 11 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_upload/mod_http_upload.lua	Sun Mar 26 23:05:31 2017 +0200
+++ b/mod_http_upload/mod_http_upload.lua	Sun Mar 26 23:07:16 2017 +0200
@@ -97,19 +97,19 @@
 	local reply = st.reply(stanza);
 	reply:tag("slot", { xmlns = xmlns });
 
-	local random;
-	repeat random = uuid();
-	until lfs.mkdir(join_path(storage_path, random))
-		or not lfs.attributes(join_path(storage_path, random, filenams))
+	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, filenams))
 
 	datamanager.list_append(origin.username, origin.host, module.name, {
-		filename = join_path(storage_path, random, filename), size = filesize, time = os.time() });
-	local slot = random.."/"..filename;
+		filename = join_path(storage_path, random_dir, filename), size = filesize, time = os.time() });
+	local slot = random_dir.."/"..filename;
 	pending_slots[slot] = origin.full_jid;
 	local base_url = module:http_url();
 	local slot_url = url.parse(base_url);
 	slot_url.path = url.parse_path(slot_url.path or "/");
-	t_insert(slot_url.path, random);
+	t_insert(slot_url.path, random_dir);
 	t_insert(slot_url.path, filename);
 	slot_url.path.is_directory = false;
 	slot_url.path = url.build_path(slot_url.path);
@@ -145,8 +145,8 @@
 		module:log("warn", "Attempt to upload to unknown slot %q", path);
 		return; -- 404
 	end
-	local random, filename = path:match("^([^/]+)/([^/]+)$");
-	if not random then
+	local random_dir, filename = path:match("^([^/]+)/([^/]+)$");
+	if not random_dir then
 		module:log("warn", "Invalid file path %q", path);
 		return 400;
 	end
@@ -155,7 +155,7 @@
 		return 400;
 	end
 	pending_slots[path] = nil;
-	local full_filename = join_path(storage_path, random, filename);
+	local full_filename = join_path(storage_path, random_dir, filename);
 	if lfs.attributes(full_filename) then
 		module:log("warn", "File %s exists already, not replacing it", full_filename);
 		return 409;
@@ -177,7 +177,7 @@
 		os.remove(full_filename);
 		return 500;
 	end
-	module:log("info", "File uploaded by %s to slot %s", uploader, random);
+	module:log("info", "File uploaded by %s to slot %s", uploader, random_dir);
 	return 201;
 end