#725 mod_storage_xmlarchive archives aren’t deleted on account removal
Reporter
Link Mauve
Owner
Zash
Created
Updated
Stars
★ (1)
Tags
Status-Fixed
Type-Defect
Priority-Medium
Link Mauve
on
What steps will reproduce the problem?
1. Enable mod_mam with mod_storage_xmlarchive.
2. Receive a message.
3. Delete your account with XEP-0077.
What is the expected output? What do you see instead?
No file should remain in ~prosody/<server JID>/archive2/username*
Instead I can still see the .list and the .xml corresponding to this user.
What version of the product are you using? On what operating system?
hg:bdaff978c790 (0.10) on ArchLinux current.
Please provide any additional information below.
N/A
Zash
on
Changes
owner Zash
tags Status-Started
Zash
on
What I believe happens here is:
An user is deleted, `storagemanager.purge()` is called.
This loops over all enabled storage drivers and tells the them to purge the user.
If mod_storage_internal performs a purge (by calling datamanager.purge()) before mod_storage_xmlarchive, then the date list file used by the later is deleted.
The root of the problem is that we do not have any idea which stores have user-related data in them.
Zash
on
Could you test this patch:
diff -r 623e23190c3e mod_storage_xmlarchive/mod_storage_xmlarchive.lua
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Mon Jan 02 21:04:36 2017 +0100
+++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Wed Jan 04 03:53:19 2017 +0100
@@ -263,11 +263,18 @@ function provider:open(store, typ)
end
function provider:purge(username)
- for store in dm.stores(username, module.host) do
- local dates = dm.list_load(username, module.host, store) or empty;
- if dates[1] and type(dates[1]) == "string" and dates[1]:match("^%d%d%d%d%-%d%d%-%d%d$") then
- module:log("info", "Store %s looks like an archive store, emptying it...", store);
- provider:open(store, "archive"):delete(username);
+ local encoded_username = dm.path_encode(username .. "@");
+ local basepath = prosody.paths.data .. "/" .. dm.path_encode(module.host);
+ for store in lfs.dir(basepath) do
+ store = basepath .. "/" .. dm.path_encode(store);
+ if lfs.attributes(store, "mode") == "directory" then
+ for file in lfs.dir(store) do
+ if file:sub(1, #encoded_username) == encoded_username then
+ if file:sub(-4) == ".xml" or file:sub(-5) == ".list" then
+ os.remove(store .. "/" .. file);
+ end
+ end
+ end
end
end
return true;
Zash
on
Changes
titlemod_mam’s archives aren’t deleted on account removal mod_storage_xmlarchive archives aren’t deleted on account removal
What steps will reproduce the problem? 1. Enable mod_mam with mod_storage_xmlarchive. 2. Receive a message. 3. Delete your account with XEP-0077. What is the expected output? What do you see instead? No file should remain in ~prosody/<server JID>/archive2/username* Instead I can still see the .list and the .xml corresponding to this user. What version of the product are you using? On what operating system? hg:bdaff978c790 (0.10) on ArchLinux current. Please provide any additional information below. N/A
What I believe happens here is: An user is deleted, `storagemanager.purge()` is called. This loops over all enabled storage drivers and tells the them to purge the user. If mod_storage_internal performs a purge (by calling datamanager.purge()) before mod_storage_xmlarchive, then the date list file used by the later is deleted. The root of the problem is that we do not have any idea which stores have user-related data in them.
Could you test this patch: diff -r 623e23190c3e mod_storage_xmlarchive/mod_storage_xmlarchive.lua --- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Mon Jan 02 21:04:36 2017 +0100 +++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua Wed Jan 04 03:53:19 2017 +0100 @@ -263,11 +263,18 @@ function provider:open(store, typ) end function provider:purge(username) - for store in dm.stores(username, module.host) do - local dates = dm.list_load(username, module.host, store) or empty; - if dates[1] and type(dates[1]) == "string" and dates[1]:match("^%d%d%d%d%-%d%d%-%d%d$") then - module:log("info", "Store %s looks like an archive store, emptying it...", store); - provider:open(store, "archive"):delete(username); + local encoded_username = dm.path_encode(username .. "@"); + local basepath = prosody.paths.data .. "/" .. dm.path_encode(module.host); + for store in lfs.dir(basepath) do + store = basepath .. "/" .. dm.path_encode(store); + if lfs.attributes(store, "mode") == "directory" then + for file in lfs.dir(store) do + if file:sub(1, #encoded_username) == encoded_username then + if file:sub(-4) == ".xml" or file:sub(-5) == ".list" then + os.remove(store .. "/" .. file); + end + end + end end end return true;
mod_mam’s archives aren’t deleted on account removalmod_storage_xmlarchive archives aren’t deleted on account removalCommitted above patch as https://hg.prosody.im/prosody-modules/rev/1b081c8fc1d9
Changes