diff mod_storage_s3/mod_storage_s3.lua @ 5758:32bc648e3892

mod_storage_s3: Fix passing of prefixes, should not be urlencoded
author Kim Alvefur <zash@zash.se>
date Sat, 02 Dec 2023 12:20:36 +0100
parents 72b0fa7e36dc
children c7affea8bb24
line wrap: on
line diff
--- a/mod_storage_s3/mod_storage_s3.lua	Sat Dec 02 11:48:19 2023 +0100
+++ b/mod_storage_s3/mod_storage_s3.lua	Sat Dec 02 12:20:36 2023 +0100
@@ -175,7 +175,7 @@
 
 function keyval:users()
 	local bucket_path = url.build_path({ is_absolute = true; bucket; is_directory = true });
-	local prefix = url.build_path({ jid.escape(module.host); is_directory = true });
+	local prefix = jid.escape(module.host) .. "/";
 	local list_result, err = async.wait_for(new_request(self, "GET", bucket_path, { prefix = prefix }))
 	if err or list_result.code ~= 200 then
 		return nil, err;
@@ -238,7 +238,7 @@
 
 function archive:find(username, query)
 	local bucket_path = url.build_path({ is_absolute = true; bucket; is_directory = true });
-	local prefix = { jid.escape(module.host); jid.escape(username or "@"); jid.escape(self.store); is_directory = true };
+	local prefix = { jid.escape(module.host); jid.escape(username or "@"); jid.escape(self.store) };
 	if not query then
 		query = {};
 	end
@@ -250,7 +250,7 @@
 		end
 	end
 
-	prefix = url.build_path(prefix);
+	prefix = table.concat(prefix, "/").."/";
 	local list_result, err = async.wait_for(new_request(self, "GET", bucket_path, {
 		prefix = prefix;
 		["max-keys"] = query["max"] and tostring(query["max"]);