comparison 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
comparison
equal deleted inserted replaced
5757:08a635862201 5758:32bc648e3892
173 return async.wait_for(new_request(self, "PUT", self:_path(user), nil, data)); 173 return async.wait_for(new_request(self, "PUT", self:_path(user), nil, data));
174 end 174 end
175 175
176 function keyval:users() 176 function keyval:users()
177 local bucket_path = url.build_path({ is_absolute = true; bucket; is_directory = true }); 177 local bucket_path = url.build_path({ is_absolute = true; bucket; is_directory = true });
178 local prefix = url.build_path({ jid.escape(module.host); is_directory = true }); 178 local prefix = jid.escape(module.host) .. "/";
179 local list_result, err = async.wait_for(new_request(self, "GET", bucket_path, { prefix = prefix })) 179 local list_result, err = async.wait_for(new_request(self, "GET", bucket_path, { prefix = prefix }))
180 if err or list_result.code ~= 200 then 180 if err or list_result.code ~= 200 then
181 return nil, err; 181 return nil, err;
182 end 182 end
183 local list_bucket_result = xml.parse(list_result.body); 183 local list_bucket_result = xml.parse(list_result.body);
236 end)); 236 end));
237 end 237 end
238 238
239 function archive:find(username, query) 239 function archive:find(username, query)
240 local bucket_path = url.build_path({ is_absolute = true; bucket; is_directory = true }); 240 local bucket_path = url.build_path({ is_absolute = true; bucket; is_directory = true });
241 local prefix = { jid.escape(module.host); jid.escape(username or "@"); jid.escape(self.store); is_directory = true }; 241 local prefix = { jid.escape(module.host); jid.escape(username or "@"); jid.escape(self.store) };
242 if not query then 242 if not query then
243 query = {}; 243 query = {};
244 end 244 end
245 245
246 if query["start"] and query["end"] and dt.date(query["start"]) == dt.date(query["end"]) then 246 if query["start"] and query["end"] and dt.date(query["start"]) == dt.date(query["end"]) then
248 if query["with"] then 248 if query["with"] then
249 table.insert(prefix, jid.escape(query["with"])); 249 table.insert(prefix, jid.escape(query["with"]));
250 end 250 end
251 end 251 end
252 252
253 prefix = url.build_path(prefix); 253 prefix = table.concat(prefix, "/").."/";
254 local list_result, err = async.wait_for(new_request(self, "GET", bucket_path, { 254 local list_result, err = async.wait_for(new_request(self, "GET", bucket_path, {
255 prefix = prefix; 255 prefix = prefix;
256 ["max-keys"] = query["max"] and tostring(query["max"]); 256 ["max-keys"] = query["max"] and tostring(query["max"]);
257 })); 257 }));
258 if err or list_result.code ~= 200 then 258 if err or list_result.code ~= 200 then