Mercurial > prosody-modules
comparison mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 6513:5fb466693e85
mod_storage_xmlarchive: Ensure list index files are removed
using os.remove() on the list files leaves the new index files behind
since util.datamanager does not know they are removed.
Thanks Link Mauve
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Tue, 07 Apr 2026 21:10:54 +0200 |
| parents | f6c83a8425f2 |
| children | 3b605bfc94aa |
comparison
equal
deleted
inserted
replaced
| 6512:f6c83a8425f2 | 6513:5fb466693e85 |
|---|---|
| 421 table.sort(remaining_dates); | 421 table.sort(remaining_dates); |
| 422 local ok, err = dm.list_store(username, self.host, self.store, remaining_dates); | 422 local ok, err = dm.list_store(username, self.host, self.store, remaining_dates); |
| 423 if not ok then return ok, err; end | 423 if not ok then return ok, err; end |
| 424 for d = 1, #dates do | 424 for d = 1, #dates do |
| 425 if dates[d] < before then | 425 if dates[d] < before then |
| 426 os.remove(dm.getpath(username .. "@" .. dates[d], self.host, self.store, "list")); | 426 dm.list_store(username .. "@" .. dates[d], self.host, self.store, empty); |
| 427 os.remove(dm.getpath(username .. "@" .. dates[d], self.host, self.store, "xml")); | 427 os.remove(dm.getpath(username .. "@" .. dates[d], self.host, self.store, "xml")); |
| 428 end | 428 end |
| 429 end | 429 end |
| 430 return true; | 430 return true; |
| 431 end | 431 end |
| 455 end | 455 end |
| 456 | 456 |
| 457 function provider:purge(username) | 457 function provider:purge(username) |
| 458 local encoded_username = dm.path_encode((username or "@") .. "@"); | 458 local encoded_username = dm.path_encode((username or "@") .. "@"); |
| 459 local basepath = prosody.paths.data .. "/" .. dm.path_encode(module.host); | 459 local basepath = prosody.paths.data .. "/" .. dm.path_encode(module.host); |
| 460 for store in lfs.dir(basepath) do | 460 for rawstore in lfs.dir(basepath) do |
| 461 local store = basepath .. "/" .. dm.path_encode(store); | 461 local encoded_store = basepath .. "/" .. dm.path_encode(rawstore); |
| 462 if lfs.attributes(store, "mode") == "directory" then | 462 if lfs.attributes(encoded_store, "mode") == "directory" then |
| 463 for file in lfs.dir(store) do | 463 for file in lfs.dir(encoded_store) do |
| 464 if file:sub(1, #encoded_username) == encoded_username then | 464 if file:sub(1, #encoded_username) == encoded_username then |
| 465 if file:sub(-4) == ".xml" or file:sub(-5) == ".list" then | 465 if file:sub(-4) == ".xml" or file:sub(-5) == ".list" or file:sub(-5) == ".lidx" then |
| 466 os.remove(store .. "/" .. file); | 466 os.remove(encoded_store .. "/" .. file); |
| 467 end | 467 end |
| 468 end | 468 end |
| 469 end | 469 end |
| 470 return true; | 470 return true; |
| 471 end | 471 end |
